3.5、后端开发基础PHP - PHP简介及PHP基本函数(下)作业 - Locked

j0h   ·   发表于 2018-6-10   ·   CTF&WP专版
---------------------------------Form登录表单----------------------------------------
<!DOCTYPE html>
<html>
<head>
<title>登录验证</title>
</head>
<body>
        <form  action="yanzhen.php" method="get">
            <p>帐号:<input type="text" name="username"/></p>
            <p>密码:<input type="text" name="password"></p>
            <input type="submit" value="登录">
        </form>
</body>
</html>


---------------------------------PHP登录验证----------------------------------------

<!DOCTYPE html>

<html>

<body>

<?php

$servername = "127.0.0.1";

$username = "root";

$password = "root";

$dbname = "mysql";

 

// 创建连接

$conn = new mysqli($servername, $username, $password, $dbname);

// 检查链接

if ($conn->connect_error) {

    die("连接失败: " . $conn->connect_error);

}

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

$password=$_GET['password'];

$sql = "SELECT username,password FROM name where username='"."$user_name"."' and password='"."$password"."'";

$result = mysqli_query($conn,$sql);

if(mysqli_num_rows($result) > 0) {

    echo "登录成功";

} else {

    echo "查询失败";

}

mysqli_close($conn);

?>

</body>

</html>


---------------------------------登录验证图----------------------------------------

---------------------------------防SQL待提供----------------------------------------


打赏我,让我更有动力~

1 Reply   |  Until 2018-6-11 | 666 View

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

通过。

评论列表

  • 加载数据中...

编写评论内容
LoginCan Publish Content
返回顶部 投诉反馈

掌控者 © 2016. All Rights Reserved. 掌控者

Powered by 掌控者 Version 2.1.3