php链接mysql数据库最简单登录

<?php
header("Content-type:text/html;charset=utf-8");
$account = $_POST['account'];
$password = $_POST['password'];
echo '
<form action="Login.php" method="POST">
账号:<input type="text" name="account"><br><br>
密码:<input type="password" name="password"><br><br>
<input type="submit" value="登录">
</form>
';
function login($account,$password){
$conn = mysql_connect ( "localhost" , "root" , "root" );
$result = mysql_db_query ( "数据库" , "select * from <表名> where ACCOUNT = '$account' and PASSWORD = '$password'" , $conn );
$row = mysql_fetch_row ( $result );
if ($row != null){
       //判断成立跳转下一页面
echo '<script language="javascript">location.href="test1/index.php"</script>';
}else{
echo '登录失败';
}
mysql_free_result ( $result );
mysql_close ( $conn );
}
login($account,$password);
?>
posted @ 2017-08-31 11:10  X_A_M  阅读(735)  评论(0编辑  收藏  举报