Blogger Information
Blog 2
fans 1
comment 0
visits 1468
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
header()误用
Will的博客
Original
752 people have browsed it

<?php
header('content-type:text/html;charset=utf-8');
include 'connection.php';
//header('content-type:text/html;charset=utf-8');
$username = isset($_POST['username'])?$_POST['username']:"";
$password = isset($_POST['password'])?$_POST['password']:"";
$username = trim($username);
$password = trim($password);
if($username==""||$password=="")
{
    echo "<script>alert('用户名或密码为空,请重新输入!');history.back();</script>";

}
else{
    $password = md5($password);

    $query = "select * from user where name_user=$username;";
    $result = mysqli_query($link, $query);
    if($result&&mysqli_num_rows($result))
    {
        $data = mysqli_fetch_assoc($result);
        if($password==$data['password_user'])
        {
            setcookie("username",$username,time()+60*60*24);
            setcookie("password",$password,time()+60*60*10);
            mysqli_close($link);
            header("location:view.php");
        }
        else
        {
            //echo "<script>alert('密码错误,请重新输入密码!');history.back();</script>";
             echo "<script>alert('用户名不存在,请去注册!');</script>";
             header("location:sign.php");
/////////这里出了一点问题,执行了跳转,但是前面的警告框没有效果
        }
    }
    else
    {
        echo "<script>alert('用户名不存在,请去注册!');location.href='sign.php';</script>";
    }
}
?>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post