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

j0h   ·   发表于 2018-06-10 21:08:42   ·   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 条回复   |  直到 2018-6-11 | 1540 次浏览

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

通过。

评论列表

  • 加载数据中...

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

© 2016 - 2024 掌控者 All Rights Reserved.