后端开发基础PHP - PHP简介及PHP基本函数(下)【作业】修正

mrchen   ·   发表于 2018-07-19 16:03:49   ·   CTF&WP专版

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>3.5作业</title>

</head>

<body>

<p>用户登录</p>

<form method="get" action="..\..\..\3.5.php">

<table border="1">

<tr>

<th>name:</th>

<th><input type="text"></th>

</tr>

<tr>

<td>password:</td>

<td><input type="password"></td>

</tr>

</table>

<p><input type="submit" value="登陆">

</form>

</body>

</html>



<?php

$servername="host";

$username="root";

$userpassword="root";

$dbname="zuoye";

$conn=mysqli_connect("$servername","$username","$userpassword","$dbname");

if(!$conn)

echo("连接失败");

$name=$_get['text'];

$password=$_get['password'];

$sql="select id from table where username=$name and userpassword=$password"; 

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

if($result)

echo "登陆成功";

else

echo "账户或密码错误" ;

?>


打赏我,让我更有动力~

1 条回复   |  直到 2018-7-20 | 1253 次浏览

Track-方丈
发表于 2018-7-20

提交表单时,action指定的必须是相对地址,不能是文件的绝对地址。

get方式提交的表单必须是在$_GET数组里面才能获取到,而不是$_POST。

MySQL中,判断条件是否成立时,只需使用一个=,而不是==。

评论列表

  • 加载数据中...

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

© 2016 - 2024 掌控者 All Rights Reserved.