纪念一下自己写的东西.. 都说很垃圾就是了
直接用XAMPP做的 菜鸟网上学的PHP和HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>学生信息</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <center> <br><br> <h2>学生信息管理</h2> <a href="myindex.php">浏览学生</a> <a href="login.php">增删学生</a> <hr> <br><br><br><br><br> <form action="search.php" method="post"> <input type="text" name = "fname"><br> <input type="radio" name = "vehicle" value="name">姓名<br> <input type="radio" name = "vehicle" value="num" checked="checked">学号<br> <input type="radio" name = "vehicle" value="course" checked="checked">课程<br> <input type="submit" value = "搜索"> </form> </center> <br><br><br><br><br><br><br><br><br><br><br><br><br> </body> </html>
<!DOCTYPE html> <head> <meta charset = "UTF-8"> <title>学生信息管理</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <center> <h3>浏览学生信息<h3> <table width = "800" border = "1"> <tr> <th>学号</th> <th>姓名</th> <th>课程1</th> <th>课程2</th> <th>课程3</th> <th>课程4</th> <th>课程5</th> </tr> <?php $dbhost = "localhost:3306"; $dbuser = "root"; $dbpass = ""; $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_query($conn , "set names utf8"); mysqli_select_db($conn, 'demo'); $sql = "SELECT * FROM stu"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "<td>{$row['课程1']} </td> "; echo "<td>{$row['课程2']} </td> "; echo "<td>{$row['课程3']} </td> "; echo "<td>{$row['课程4']} </td> "; echo "<td>{$row['课程5']} </td> "; echo "</tr>"; } ?> </table> </center> <h3> <a href="test1.php">返回首页</a> </h3> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>课程查询</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <center> <?php $dbhost = "localhost:3306"; $dbuser = "root"; $dbpass = ""; $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_query($conn , "set names utf8"); mysqli_select_db($conn, 'demo'); $sqlll = $_POST["fname"]; $sqlcheck = $_POST["vehicle"]; echo "<br><br><br><br><br><br><br><br><br><br><br><br><br>"; if($sqlcheck === 'course') { echo "<table width = '400' border = '2'>"; echo "<tr>"; echo "<th>学号</th>"; echo "<th>姓名</th>"; echo "</tr>"; $sql = "SELECT `学号`, `姓名`, `课程1`, `课程2`, `课程3`, `课程4`, `课程5` FROM `stu` WHERE `课程1` LIKE '$sqlll'"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "</tr>"; } $sql = "SELECT `学号`, `姓名`, `课程1`, `课程2`, `课程3`, `课程4`, `课程5` FROM `stu` WHERE `课程2` LIKE '$sqlll'"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "</tr>"; } $sql = "SELECT `学号`, `姓名`, `课程1`, `课程2`, `课程3`, `课程4`, `课程5` FROM `stu` WHERE `课程3` LIKE '$sqlll'"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "</tr>"; } $sql = "SELECT `学号`, `姓名`, `课程1`, `课程2`, `课程3`, `课程4`, `课程5` FROM `stu` WHERE `课程4` LIKE '$sqlll'"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "</tr>"; } $sql = "SELECT `学号`, `姓名`, `课程1`, `课程2`, `课程3`, `课程4`, `课程5` FROM `stu` WHERE `课程5` LIKE '$sqlll'"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "</tr>"; } echo "</table>"; } else { if($sqlcheck === 'name') {$sql = "SELECT * FROM `stu` WHERE `姓名` LIKE '$sqlll'";} else {$sql = "SELECT * FROM `stu` WHERE `学号` LIKE '$sqlll'";} echo "<table width = '800' border = '1'>"; echo "<tr>"; echo "<th>学号</th>"; echo "<th>姓名</th>"; echo "<th>课程1</th>"; echo "<th>课程2</th>"; echo "<th>课程3</th>"; echo "<th>课程4</th>"; echo "<th>课程5</th>"; $retval = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "<tr>"; echo "<td>{$row['学号']}</td> "; echo "<td>{$row['姓名']}</td> "; echo "<td>{$row['课程1']} </td> "; echo "<td>{$row['课程2']} </td> "; echo "<td>{$row['课程3']} </td> "; echo "<td>{$row['课程4']} </td> "; echo "<td>{$row['课程5']} </td> "; echo "</tr>"; } echo "</table>"; } ?> </center> <h3> <a href="test1.php">返回首页</a> </h3> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>添加学生</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <?php $use = $_POST["user"]; $pass = $_POST["password"]; echo "<br><br><br><br><br><br><br><br><br><br>"; echo "<center>"; if($use === "admin" && $pass == "123") { echo "<h1>Welcome, lwq</h1>"; echo "<br>"; echo "<form action='addaction.php' method='post'>"; echo "<input type='text' name = 's1'>学号<br>"; echo "<input type='text' name = 's2'>姓名<br>"; echo "<input type='text' name = 's3'>课程1<br>"; echo "<input type='text' name = 's4'>课程2<br>"; echo "<input type='text' name = 's5'>课程3<br>"; echo "<input type='text' name = 's6'>课程4<br>"; echo "<input type='text' name = 's7'>课程5<br>"; echo "<input type='submit' value = '添加'>"; echo "</form>"; echo "<br><br><br>"; echo "<form action='delete.php' method='post'>"; echo "<input type='text' name = 'd1'>学号<br>"; echo "<input type='text' name = 'd2'>姓名<br>"; echo "<input type='submit' value = '删除'>"; echo "</form>"; } else { echo "sorry, assess denied!!<br>"; header("Location:test1.php"); } echo "</center>"; ?> <h3> <a href="test1.php">返回首页</a> </h3> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>登陆</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <br><br><br><br><br><br><br><br><br><br> <center> <form action="add.php" method="post"> 用户: <input type="text" name="user"><br> 密码: <input type="password" name="password"> <input type="submit" value = "登陆"> </form> </center> <h3> <a href="test1.php">返回首页</a> </h3> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>添加学生</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <br><br><br><br><br><br><br><br><br><br> <center> <?php $r1 = $_POST["s1"]; $r2 = $_POST["s2"]; $r3 = $_POST["s3"]; $r4 = $_POST["s4"]; $r5 = $_POST["s5"]; $r6 = $_POST["s6"]; $r7 = $_POST["s7"]; $dbhost = "localhost:3306"; $dbuser = "root"; $dbpass = ""; $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_query($conn , "set names utf8"); mysqli_select_db($conn, 'demo'); $sql = "INSERT INTO `stu` (`学号`, `姓名`, `课程1`, `课程2`, `课程3`, `课程4`, `课程5`) VALUES ('$r1', '$r2', '$r3', '$r4', '$r5', '$r6', '$r7');"; $retval = mysqli_query($conn, $sql); echo "添加成功"; ?> </center> <h3> <a href="add.php">继续添加</a> <a href="test1.php">返回首页</a> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>学生信息</title> </head> <style> body { background: rgba(12, 100, 129, 1) url('https://images2018.cnblogs.com/blog/1393985/201806/1393985-20180613124043614-112674236.jpg') fixed no-repeat; background-position: 50% 5%; background-size: cover; } </style> <body> <br><br><br><br><br><br><br><br><br><br> <center> <?php $t1 = $_POST["d1"]; $t2 = $_POST["d2"]; $dbhost = "localhost:3306"; $dbuser = "root"; $dbpass = ""; $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_query($conn , "set names utf8"); mysqli_select_db($conn, 'demo'); $sql = "DELETE FROM `stu` WHERE 学号 = '$t1'"; $retval = mysqli_query($conn, $sql); $sql = "DELETE FROM `stu` WHERE 姓名 = '$t2'"; $retval = mysqli_query($conn, $sql); echo "删除成功"; ?> </center> <h3> <a href="test1.php">返回首页</a> </body> </html>