我的第一个php程序

来源:互联网 发布:flash整站源码 编辑:程序博客网 时间:2024/05/17 03:35

<html>
<body>
<form name="login" action="PanDuan.php" method="POST">   
用户名<input type="text" name="name"/>
<p>密码<input type="password" name="password"/> </p>
<input name="log" type="submit" value="登录">
</form>
</body>
</html>



<?php
$mysqli=mysqli_connect("localhost","root","","myfirstphp_liuyanban");
$name=$_POST["name"];
$passowrd=$_POST["password"];
if ($name && $passowrd){
$sql = "SELECT * FROM test1 WHERE name='$name' and password='$passowrd'";
$res = mysqli_query($mysqli,$sql);
$rows=mysqli_num_rows($res);
if($rows){
header("location:success.php");
exit;
}
 else{
header("location:fail.php");
}
mysqli_free_result($res);
mysqli_close($mysqli);
}
?>

/* <?php
$name=$_POST["name"];
$passowrd=$_POST["password"];
if("1"==$name && "2"==$passowrd)
header("location:success.php");
 else
header("location:fail.php");

?> */

0 0