<?php error_reporting(0); if (isset($_post['post']) && $_post['post'] == "1") { $mysql_servername = "localhost"; $mysql_username = "root"; $mysql_password = ""; $mysql_database = "peng"; mysql_connect($mysql_servername, $mysql_username, $mysql_password); mysql_select_db($mysql_database); $name = $_post['name']; $passowrd = $_post['password']; if ($name && $passowrd) { $sql = "select * from liuyanban where name = '$name' and password='$passowrd'"; $res = mysql_query($sql); $rows = mysql_num_rows($res); if ($rows) { header("refresh:0;url=a.htm"); exit; } echo "<script language=javascript>alert('用户名密码错误');history.back();</script>"; } else { echo "<script language=javascript>alert('用户名密码不能为空');history.back();</script>"; } } else { ?> <html> <body> <form name="login" action="login.php" method=post> <input type=hidden name="post" value=1> 用户名<input type=text name="name"> <p>密码<input type=password name="password"> <p> <input name="log" type=submit value="登录"> </form> </body> </html> <?php } ?>
文章地址:
转载随意^^请带上本文地址!