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

kunpyng   ·   发表于 2018-07-19 20:42:44   ·   CTF&WP专版

<!doctype html>

<html>

<meta charest="utf-8" />

<head>有2个或多个字段的用户登录表单,点击按钮后提交到后端PHP,判断是否登陆成功</head>

<body>

<p>管理员登录</p>

<form action="a.php" method="post">

<input type="txt" name="username" value=""><br>

<input type="txt" name="password" value=""><br>

<input type="submit" name ="submit" value="提交">

</form>

</body>

</html>



文件a.php

<?php

header('content-type:a/html;charset=utf-8');

$username=$_POST['username'];

$password=$_POST['password'];

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

if (!$con)

{

  die('Could not connect:'. mysql_error());

}

$result = mysqli_query($conn,"SELECT * FROM user WHERE username='".mysql_real_escape_string($username)."'AND password='".mysql_real_escape_string($password)."'");          


$row=mysql_fetch_row($result);

if($row>0)

{

echo"登陆成功";

}

else

{

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

}

mysqli_close($conn);

?>


打赏我,让我更有动力~

1 Reply   |  Until 2018-7-20 | 995 View

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

通过,金币奖励已发放、

评论列表

  • 加载数据中...

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

© 2016 - 2022 掌控者 All Rights Reserved.