我正在尝试登录,但直接带我到脚本(用户名/密码错误),我连接到数据库。 [英] I'm trying to login but take me straight to the script (username/password wrong), and I am connected to database.
本文介绍了我正在尝试登录,但直接带我到脚本(用户名/密码错误),我连接到数据库。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
session_start();
include_once 'connection.php';
if(isset($_SESSION['admin'])!="")
{
header("Location: adminhome.php");
}
if(isset($_POST['btn-login']))
{
$uname = mysql_real_escape_string($_POST['username']);
$upass = mysql_real_escape_string($_POST['pass']);
$uname = trim($uname);
$upass = trim($upass);
$res=mysql_query("SELECT admin_id, admin_email, admin_pass FROM admin WHERE admin_name='$uname'");
$row=mysql_fetch_array($res);
$count = mysql_num_rows($res); // if uname/pass correct it returns must be 1 row
if($count == 1 && $row['admin_pass']==md5($upass))
{
$_SESSION['admin'] = $row['admin_id'];
header("Location: userhome.php");
}
else
{
?>
<script>alert('Username / Password Seems Wrong !');</script>
<?php
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Member and Admin login</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<center>
<div id="login-form">
<form method="post">
<table align="center" width="30%" border="0">
<tr>
<td><input type="text" name="username" placeholder="Your username" required /></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Your Password" required /></td>
</tr>
<tr>
<td><button type="submit" name="btn-login">Sign In</button></td>
</tr>
<tr>
<td><a href="index.php">Click here for Customer login</a></td>
</tr>
<tr>
<td><a href="register.php">Sign Up Here</a></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>
我的尝试:
我也有与客户登录相同的表格,但不同的登录。对于客户登录它是有效的,这个不是。它说用户名和密码是错误的。我已将我的值插入到phpadmin xampp服务器中。
任何人都可以指出我的代码有什么问题。我不善于编码。这是我的课程作业
What I have tried:
I have the same form with customer login too, but different login. For customer login it works, this one is not.it says username and password is wrong. I have inserted my values too into phpadmin xampp server.
Can anyone pointed out what wrong with my codes. Im not good with coding. This is my course assignment
推荐答案
_SESSION [' admin '])!= )
{
header ( 位置:adminhome.php);
}
if(isset(
_SESSION['admin'])!="") { header("Location: adminhome.php"); } if(isset(
_POST [' btn-login']))
{
_POST['btn-login'])) {
uname = mysql_real_escape_string(
uname = mysql_real_escape_string(
这篇关于我正在尝试登录,但直接带我到脚本(用户名/密码错误),我连接到数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文