PHP作业_下 - 已锁定

木木   ·   发表于 2018-06-29 23:35:23   ·   CTF&WP专版

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8"/>

<title>登录页面</title>

</head>

<body>

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

<form name="denglu" method="POST" action="2.php">

用户名:<input type="text" name="username" value="" /><br/>

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

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

</form>

</body>

</html>




<?php

//连接数据库

$conn=mysql_connect("localhost","root","root","db_test")or defead("连接数据库失败");

//选择数据库

mysql_select_db($conn,"db_test");

//获取表单数据

$account=$_POST['account'];

$password=$_POST['password'];

//$password=123456($password);

$sql="select * from admin where account='{$account}'";  

//执行sql语句

$result=mysql_query($sql); 

//获取记录数

$num=mysql_num_rows($result); 

if($num){

   $row=mysql_fetch_array($result);

   if($password===$row['password']){

    echo "登陆成功";}

else{

echo "密码错误";

echo "<a href='http://localhost'>返回登陆页面</a>";

}}

?>


打赏我,让我更有动力~

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

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

通过。

评论列表

  • 加载数据中...

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

© 2016 - 2024 掌控者 All Rights Reserved.