parent
990e1d3e9c
commit
e188c4ec66
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>连接数据库</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
$conn=mysqli_connect("localhost","root","3256137");
|
||||
if(!$conn){
|
||||
die("无法连接到mysql数据库:".mysqli_error($conn));}
|
||||
mysqli_select_db($conn,'xs');
|
||||
mysqli_set_charset($conn,"utf8");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>destroy_session</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
echo "<script>url=\"login.html\";window.location.href=url;</script>";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>login.php</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include("connect.php");
|
||||
$username=$_POST['username'];
|
||||
$password=$_POST['password'];
|
||||
$sql="select userid from user where username='$username'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result)<=0)
|
||||
{
|
||||
echo "<script>alert(\"该用户不存在\");</script>";
|
||||
echo "<script>url=\"login.html\";window.location.href=url;</script>";}
|
||||
$sql="select userid from user where username='$username' and password='$password'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result)>0){
|
||||
echo "<script>url=\"index.php\";window.location.href=url;</script>";}
|
||||
else{
|
||||
echo "<script>alert(\"用户名或密码错误\");</script>";
|
||||
echo "<script>url=\"login.html\";window.location.href=url;</script>";}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
<?php
|
||||
session_start();
|
||||
include("connect.php");
|
||||
$username=$_POST['username'];
|
||||
$password=$_POST['password'];
|
||||
$sql="select userid from user where username='$username' and password='$password'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result)>0){
|
||||
$_SESSION['username']=$username;
|
||||
echo "<script>url=\"index.php\",window.location.href=url;</script>";}
|
||||
else{
|
||||
echo "<script>alert(\"用户名或密码错误\");</script>";
|
||||
echo "<script>url=\"login.html\";window.location.href=url;</script>";}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>register.php</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
$username=$_POST['username'];
|
||||
$password=$_POST['password'];
|
||||
$repassword=$_POST['repassword'];
|
||||
if($password!=$repassword){
|
||||
echo "<script>alert(\"两次密码不一致\");</script>";
|
||||
echo "<script>url=\"register.html\";window.location.href=url;</script>";
|
||||
exit();}
|
||||
include("connect.php");
|
||||
$sql="select userid from user where username='$username'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result)>0){
|
||||
echo "<script>alert(\"该用户已被注册\");</script>";
|
||||
echo "<script>url=\"register.html\";window.location.href=url;</script>";
|
||||
exit();}
|
||||
$sql="insert into user values(null,'$username','$password')";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result){
|
||||
echo "<script>alert(\"注册成功,登录\");</script>";
|
||||
echo "<script>url=\"login.html\";window.location.href=url;</script>";}
|
||||
else{
|
||||
die("Error: ".mysqli_error($conn));}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>score.php</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
?>
|
||||
<?php
|
||||
include("connect.php");
|
||||
$name=$_POST['XM'];
|
||||
$kcm=$_POST['KCM'];
|
||||
$score=$_POST['CJ'];
|
||||
if(isset($_POST['录入']))
|
||||
{
|
||||
if(!strlen($name))
|
||||
{
|
||||
echo "<script>alert(\"姓名处不能为空\");</script>";
|
||||
exit();}
|
||||
$sql="select XM,KCM from cj where XM='$name' and KCM='$kcm'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<script>alert(\"该学生此课程成绩已录入\");</script>";
|
||||
exit();}
|
||||
$sql="insert into cj(XM,KCM,CJ) values('$name','$kcm','$score')";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result)
|
||||
{
|
||||
echo "<script>alert(\"录入成功\");</script>";
|
||||
$result=mysqli_query($conn,"select *from cj where XM='$name' and KCM='$kcm';");
|
||||
$row=mysqli_fetch_array($result);
|
||||
echo "<table border <tr><th>姓名</th><th>课程名</th><th>成绩</th></tr>";
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=80px>".$row['KCM']."</th>";
|
||||
echo "<th width=60px>".$row['CJ']."</th></tr>";
|
||||
echo "</table>";}
|
||||
else{
|
||||
echo "<script>alert(\"录入失败\");</script>";
|
||||
exit();}
|
||||
}
|
||||
if(isset($_POST['更新']))
|
||||
{
|
||||
if(!strlen($name)||!strlen($kcm)||!strlen($score))
|
||||
{
|
||||
echo "<script>alert(\"请填写完整信息\");</script>";
|
||||
exit();}
|
||||
$sql="select XM from cj where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(!mysqli_num_rows($result)){
|
||||
echo "<script>alert(\"该学生不存在\");</script>";
|
||||
exit();}
|
||||
$sql="update cj set CJ='$score' where XM='$name' and KCM='$kcm'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result)
|
||||
{
|
||||
echo "<script>alert(\"更新成功\");</script>";
|
||||
$result=mysqli_query($conn,"select *from cj where XM='$name' and KCM='$kcm'");
|
||||
$row=mysqli_fetch_array($result);
|
||||
echo "<table border <tr><th>姓名</th><th>课程名</th><th>成绩</th></tr>";
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=80px>".$row['KCM']."</th>";
|
||||
echo "<th width=40px>".$row['CJ']."</th></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"更新失败\");</script>";
|
||||
exit();}
|
||||
}
|
||||
if(isset($_POST['查询']))
|
||||
{
|
||||
if(strlen($name))
|
||||
{
|
||||
$sql="select *from cj where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<table border <tr><th>姓名</th><th>课程名</th><th>成绩</th></tr>";
|
||||
while($row=mysqli_fetch_array($result))
|
||||
{
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=80px>".$row['KCM']."</th>";
|
||||
echo "<th width=60px>".$row['CJ']."</th></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"该学生不存在\");</script>";
|
||||
exit();}
|
||||
}
|
||||
else if(strlen($kcm))
|
||||
{
|
||||
$sql="select *from cj where KCM='$kcm'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<table border <tr><th>姓名</th><th>课程名</th><th>成绩</th></tr>";
|
||||
while($row=mysqli_fetch_array($result))
|
||||
{
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=80px>".$row['KCM']."</th>";
|
||||
echo "<th width=60px>".$row['CJ']."</th></tr>";}
|
||||
echo "</table>";}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"该课程无学生选择\");</script>";
|
||||
exit();}
|
||||
}
|
||||
}
|
||||
if(isset($_POST['删除']))
|
||||
{
|
||||
if(!strlen($name)&&!strlen($kcm))
|
||||
{
|
||||
echo "<script>alert(\"姓名不能为空或课程名不能为空\");</script>";
|
||||
exit();}
|
||||
$sql="select XM from cj where XM='$name' and KCM='$kcm'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(!$result)
|
||||
{
|
||||
echo "<script>alert(\"该学生不存在\");</script>";
|
||||
exit();}
|
||||
$sql="delete from cj where XM='$name' and KCM='$kcm'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result)
|
||||
{
|
||||
echo "<script>alert(\"删除成功\");</script>";
|
||||
exit();}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"删除失败\");</script>";
|
||||
exit();}
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>student.php</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
session_start();
|
||||
?>
|
||||
<?php
|
||||
include("connect.php");
|
||||
$name=$_POST['XM'];
|
||||
$xb=$_POST['XB'];
|
||||
$birthday=$_POST['CSSJ'];
|
||||
$kcs=$_POST['KCS'];
|
||||
if(isset($_POST['录入']))
|
||||
{
|
||||
if(!strlen($name))
|
||||
{
|
||||
echo "<script>alert(\"姓名不能为空\");</script>";
|
||||
exit();}
|
||||
$sql="select XM from student where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<script>alert(\"该学生已存在\");</script>";
|
||||
exit();}
|
||||
$sql="insert into student(XM,XB,CSSJ,KCS) values('$name','$xb','$birthday','$kcs')";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result)
|
||||
{
|
||||
echo "<script>alert(\"录入成功\");</script>";
|
||||
$result=mysqli_query($conn,"select *from student where XM='$name';");
|
||||
$row=mysqli_fetch_array($result);
|
||||
echo "<table border <tr><th>姓名</th><th>性别</th><th>出生日期</th><th>已修课程数</th></tr>";
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=40px>";
|
||||
if($row['XB']==1) echo "男";
|
||||
else echo "女";
|
||||
echo "</th>";
|
||||
echo "<th width=120px>".$row['CSSJ']."</th>";
|
||||
echo "<th width=60px>".$row['KCS']."</th></tr>";
|
||||
echo "</table>";}
|
||||
else{
|
||||
echo "<script>alert(\"录入失败\");</script>";
|
||||
exit();}
|
||||
}
|
||||
if(isset($_POST['查询']))
|
||||
{
|
||||
if(!strlen($name)&&!strlen($xb)&&!strlen($kcs)){
|
||||
$sql="select *from student";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<table border <tr><th>姓名</th><th>性别</th><th>出生日期</th><th>已修课程数</th></tr>";
|
||||
while($row = mysqli_fetch_array($result))
|
||||
{
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=40px>";
|
||||
if($row['XB']==1) echo "男";
|
||||
else echo "女";
|
||||
echo "</th>";
|
||||
echo "<th width=120px>".$row['CSSJ']."</th>";
|
||||
echo "<th width=60px>".$row['KCS']."</th></tr>";}}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"无学生\");</script>";
|
||||
exit();}
|
||||
}
|
||||
if(strlen($name))
|
||||
{
|
||||
$sql="select *from student where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
$result=mysqli_query($conn,"select *from student where XM='$name'");
|
||||
$row=mysqli_fetch_array($result);
|
||||
echo "<table border <tr><th>姓名</th><th>性别</th><th>出生日期</th><th>已修课程数</th></tr>";
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=40px>";
|
||||
if($row['XB']==1) echo "男";
|
||||
else echo "女";
|
||||
echo "</th>";
|
||||
echo "<th width=120px>".$row['CSSJ']."</th>";
|
||||
echo "<th width=60px>".$row['KCS']."</th></tr>";
|
||||
echo "</table>";}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"该学生不存在\");</script>";
|
||||
exit();}
|
||||
}
|
||||
else if(strlen($xb))
|
||||
{
|
||||
$sql="select *from student where XB='$xb'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<table border <tr><th>姓名</th><th>性别</th><th>出生日期</th><th>已修课程数</th></tr>";
|
||||
while($row = mysqli_fetch_array($result))
|
||||
{
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=40px>";
|
||||
if($row['XB']==1) echo "男";
|
||||
else echo "女";
|
||||
echo "</th>";
|
||||
echo "<th width=120px>".$row['CSSJ']."</th>";
|
||||
echo "<th width=60px>".$row['KCS']."</th></tr>";
|
||||
}
|
||||
echo "</table>";}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"查询无数据\");</script>";
|
||||
exit();}
|
||||
}
|
||||
else if(strlen($kcs))
|
||||
{
|
||||
$sql="select *from student where KCS='$kcs'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(mysqli_num_rows($result))
|
||||
{
|
||||
echo "<table border <tr><th>姓名</th><th>性别</th><th>出生日期</th><th>已修课程数</th></tr>";
|
||||
while($row = mysqli_fetch_array($result))
|
||||
{
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=40px>";
|
||||
if($row['XB']==1) echo "男";
|
||||
else echo "女";
|
||||
echo "</th>";
|
||||
echo "<th width=120px>".$row['CSSJ']."</th>";
|
||||
echo "<th width=60px>".$row['KCS']."</th></tr>";}
|
||||
echo "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"查询无数据\");</script>";
|
||||
exit();}
|
||||
}
|
||||
}
|
||||
if(isset($_POST['删除']))
|
||||
{
|
||||
if(!strlen($name))
|
||||
{
|
||||
echo "<script>alert(\"姓名不能为空\");</script>";
|
||||
exit();}
|
||||
$sql="select XM from student where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(!mysqli_num_rows($result))
|
||||
{
|
||||
echo "<script>alert(\"该学生不存在\");</script>";
|
||||
exit();}
|
||||
$sql="delete from student where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result)
|
||||
{
|
||||
echo "<script>alert(\"删除成功\");</script>";
|
||||
exit();}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"删除失败\");</script>";
|
||||
exit();}
|
||||
}
|
||||
if(isset($_POST['更新']))
|
||||
{
|
||||
if(!strlen($name)||!strlen($xb)||!strlen($birthday)||!strlen($kcs))
|
||||
{
|
||||
echo "<script>alert(\"请把信息填写完整\");</script>";
|
||||
exit();}
|
||||
$sql="select XM from student where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if(!mysqli_num_rows($result))
|
||||
{
|
||||
echo "<script>alert(\"该学生不存在\");</script>";
|
||||
exit();}
|
||||
$sql="update student set XB='$xb',CSSJ='$birthday',KCS='$kcs' where XM='$name'";
|
||||
$result=mysqli_query($conn,$sql);
|
||||
if($result)
|
||||
{
|
||||
echo "<script>alert(\"更新成功\");</script>";
|
||||
$result=mysqli_query($conn,"select *from student where XM='$name'");
|
||||
$row=mysqli_fetch_array($result);
|
||||
echo "<table border <tr><th>姓名</th><th>性别</th><th>出生日期</th><th>已修课程数</th></tr>";
|
||||
echo "<tr><th>".$row['XM']."</th>";
|
||||
echo "<th width=40px>";
|
||||
if($row['XB']==1) echo "男";
|
||||
else echo "女";
|
||||
echo "</th>";
|
||||
echo "<th width=120px>".$row['CSSJ']."</th>";
|
||||
echo "<th width=60px>".$row['KCS']."</th></tr>";
|
||||
echo "</table>";}
|
||||
else
|
||||
{
|
||||
echo "<script>alert(\"更新失败\");</script>";
|
||||
exit();}
|
||||
}
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in new issue