-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
40 lines (39 loc) · 1.29 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
if(isset($_POST['login']) && $_SERVER['REQUEST_METHOD']=='POST'){
if( $_POST['login'] && !empty($_POST['name'])){
include_once("includes/sql_connect.php");
$n=mysqli_real_escape_string($mysql,$_POST['name']);
$p=$_POST['pass'];
//$p=mysqli_real_escape_string($mysql,$_POST['pass']);
$q="SELECT pass FROM users WHERE name='$n'";
$r=mysqli_query($mysql,$q);
if($r){
$row=mysqli_fetch_array($r);
if($row['0']==$p){
//session_start();
//$_SESSION['username']=$n;
//$_SESSION['pass']=$p;
//$_SESSION['agent']=md5($_SERVER['HTTP_USER_AGENT']);
//var_dump($row);
setcookie('username',$n);
setcookie('pass',$p);
echo "登陆成功,正在转向首页";
echo '<head> <meta http-equiv="Refresh" content="1;url=http://172.16.122.8"> </head>';
}
}//end $r
}//end login
else
echo "error,请检查账户和密码";
}//end post
else{
$page_title="Login";
include_once("includes/header.html");
echo '<form class="contactform" action="login.php" method="POST">
<Label>Name:</Label><input type="text" name="name" size="20" maxlength="30" /><br>
<Label>Pass :</Label><input type="password" name="pass" size="20" maxlength="30" /><br>
<input type="submit" name="login" value="login">
<input type="reset" name="reset" value="Reset">
</fieldset>
</form>';
}
?>