我创建了一个简单的登录门户网站,但有一些问题,我尝试了几个解决方案。我想创建一个简单的登录门户网站,但有一些问题
这是我的login.php
文件。
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="short icon" href="sopraicon.ico">
<link rel="stylesheet" href="login.css">
<body>
<form method="POST" action="process.php" >
<img src="soprasteria.png" alt="sopra steria" width="20%" align="center">
<img src="share.png" alt="share" id="img1" align="right">
<a href=""> <img src="search.png" id="img1" align="right"></a>
<input type="text" class="search" name="search" placeholder="Search.."><br>
<br> <div class="sidediv"></div>
<p class="data">Sign in to Sopra Steria</p><br>
<h3 class="h3">User Login</h3>
<br><img src="Login.jpg" alt="login iamge" height="150px" width="170px"
align="left" style="padding-left:160px"><br>  <b>Username:</b>
<br>  <input type="text" placeholder="User Name" name="username"
required id="text">
<br>  <b>Password:</b><br>  <input type="password"
placeholder="Enter Password" name="password" required id="text" min="8">
<br>  <button type="submit" id="logbtn"
name="submit">Login</button><br>
<div class="bottomdiv"></div>
</form>
</body>
</head>
</html>
这是我process.php
文件
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
mysql_connect("localhost","root","");
mysql_select_db("login");
$result = mysql_query("select * from users where username='$username'
and password='$password'") or die("failed to query
database".mysql_error());
$row = mysql_fetch_array(result);
if($row['username']==$username && $row['password']== $password){
echo"login success";
}
else{
echo"failed";
}
?>
,但我得到的错误WAMP的服务器上,你在图像中看到。 请帮我..谢谢。
在* mysql_real_escape_string之前建立mysql连接。顺便说一下,考虑将代码升级到'mysqli',因为'mysql'在PHP 5.5.0中被弃用。 –
为了在Stack Overflow上获得最佳效果,请不要发布错误消息的图像,特别是当它们太小而无法阅读时。这是一个好主意,当你收到错误信息时,要研究它们并弄清楚它们的含义。 PHP已经出现了大约二十年,错误信息非常丰富。 –
另外,在这些猖獗的网络犯罪**的日子里,只有一个傻瓜做他自己的密码验证**。请,请阅读。 http://php.net/manual/en/faq.passwords.php –