我想用PHP写一个登录页面 没有写好,不知道哪些地方错了,以下是我写的代码
<?phpmysql_connect("localhost","root","111");mysql_select_db("aaa");mysql_query("setn...
<?php
mysql_connect("localhost","root","111");
mysql_select_db("aaa");
mysql_query("set names 'utf8'");
$username=$_<a href="12.php">POST</a>['username'];
<a href="12.php">post</a>
$password=$_<a href="12.php">POST</a>['passsword'];
if(!$username){
echo '用户名不能为空';
exit();
}
if(!$password){
echo '密码不能为空';
exit();
}
$re=mysql_query("select * from login where username='".$username."'");
$row=mysql_fetch_array($re);
if($row){
if($row['password']==md5($password))
{
echo 登陆成功!;
header('12.<a href="12.php">php</a>');
}
else{
echo 密码错误!;
exit();
}
}
else{
echo 账户不存在!;
exit();
}
?>
<body>
<div class="aa">
<div style="margin-left:10%;margin-top:20%">
<form action="" method="post">
用户名:<input type="text" value="" name="name" class="ab">
<br><br>
密码:<input type="text" value="" name="password" class="ac">
<br>
<input type="submit" value=" 确 定 " style="margin-left:15%;margin-top:20%">
<input type="reset" value=" 重 置 " style="margin-left:55%;margin-top:-9%">
</form>
</div>
</div>
</body> 展开
mysql_connect("localhost","root","111");
mysql_select_db("aaa");
mysql_query("set names 'utf8'");
$username=$_<a href="12.php">POST</a>['username'];
<a href="12.php">post</a>
$password=$_<a href="12.php">POST</a>['passsword'];
if(!$username){
echo '用户名不能为空';
exit();
}
if(!$password){
echo '密码不能为空';
exit();
}
$re=mysql_query("select * from login where username='".$username."'");
$row=mysql_fetch_array($re);
if($row){
if($row['password']==md5($password))
{
echo 登陆成功!;
header('12.<a href="12.php">php</a>');
}
else{
echo 密码错误!;
exit();
}
}
else{
echo 账户不存在!;
exit();
}
?>
<body>
<div class="aa">
<div style="margin-left:10%;margin-top:20%">
<form action="" method="post">
用户名:<input type="text" value="" name="name" class="ab">
<br><br>
密码:<input type="text" value="" name="password" class="ac">
<br>
<input type="submit" value=" 确 定 " style="margin-left:15%;margin-top:20%">
<input type="reset" value=" 重 置 " style="margin-left:55%;margin-top:-9%">
</form>
</div>
</div>
</body> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询