PHP(下)作业提交 - 已锁定

Newgate   ·   发表于 2018-06-11 16:17:56   ·   CTF&WP专版

<!DOCTYPE html>

<html>

<head>

<title>请输入账号密码</title>

</head>

<body>

        <form  action="1.php" method="get">

            <p>帐号:<input type="text" name="username"/></p>

            <p>密码:<input type="text" name="password"></p>

            <input type="submit" value="登录">

        </form>

</body>

</html>

1.php

<?php

    $db_name="test";

    $server_name="localhost";

    $conn=mysqli_connect($server_name,"root","",$db_name);

    if(!$conn)//连不上

    {

        die("连接错误" . mysqli_connect_error()); 

        exit;

    }

    

    $curDb=mysqli_select_db($conn,$db_name);

    if(!$curDb)

    {

        die("不存在".$db_name); 

        exit;

    }

    $user_name=$_GET['username'];//获取用户名和密码

    $password=$_GET['password'];

    $login="select user_name,password from users where user_name='".$user_name."'" ;  

    echo $login ;

    

    if($user_name)

    {

        $result=mysqli_query($conn,$login);//查询用户名

        $rows=mysqli_num_rows($result);//结果遍历

        if($rows)

        {

            $mima="select user_name,password from users where user_name='".$user_name."'and password='".$password."'"; 

$result2=mysqli_query($conn,$mima);//查询用户名

            $rows2=mysqli_num_rows($result2);//结果遍历

if($rows)

{ echo "登陆成功!";}

else

{ echo "用户名或密码错误!";}

        }

        else

        {

            echo "用户名或密码错误!";

            exit;

        }

    }

    else

    {

        echo "用户名或密码错误!";

    }

?>

打赏我,让我更有动力~

1 条回复   |  直到 2018-6-13 | 1355 次浏览

Track-方丈
发表于 2018-6-13

通过

评论列表

  • 加载数据中...

编写评论内容
登录后才可发表内容
返回顶部 投诉反馈

© 2016 - 2024 掌控者 All Rights Reserved.