Home > php教程 > php手册 > php 用户登录代码

php 用户登录代码

WBOY
Release: 2016-05-25 16:42:45
Original
973 people have browsed it

<?php
error_reporting(0);
if (isset($_post[&#39;post&#39;]) && $_post[&#39;post&#39;] == "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[&#39;name&#39;];
    $passowrd = $_post[&#39;password&#39;];
    if ($name && $passowrd) {
        $sql = "select * from liuyanban where name = &#39;$name&#39; and password=&#39;$passowrd&#39;";
        $res = mysql_query($sql);
        $rows = mysql_num_rows($res);
        if ($rows) {
            header("refresh:0;url=a.htm");
            exit;
        }
        echo "<script language=javascript>alert(&#39;用户名密码错误&#39;);history.back();</script>";
    } else {
        echo "<script language=javascript>alert(&#39;用户名密码不能为空&#39;);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
}
?>
Copy after login


文章地址:

转载随意^^请带上本文地址!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template