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

awl   ·   发表于 2018-07-04 20:15:19   ·   CTF&WP专版

<!DOCTYPE html>

<head>

<meta charset="UTF-8" />

<title>T安全社区登录</title>

</head>

<body>

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

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

管理员名:<input type="text" name="username" value=""><br>

密码:    <input type="password" name="password" value="">

<br>

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

</form> 

</body>

</html>

<?php>

$con = mysql_connect("localhost","root","root");

if (!$con)

  {

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

  }

mysql_query("SET NAMES utf8");  

mysql_select_db("user",$con);  

$username =  $_POST['username'] ;  

$password =  $_POST['password'];  

$sql = "SELECT id FROM user WHERE username= '$username' and password = '$password'" ;  

$result = mysql_query($sql,$con) ;  

$row = mysql_fetch_array($result) ;  

if($row>0)  

{  

  echo 'success';  

}  

else  

{  

  echo 'failed'.mysql_error();  

}  

  

mysql_close($con);  

?>  


打赏我,让我更有动力~

1 条回复   |  直到 2018-7-5 | 1392 次浏览

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

通过。

10金币已发放。

评论列表

  • 加载数据中...

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

© 2016 - 2024 掌控者 All Rights Reserved.