这是一个奇怪的问题
当我继续在login.php
我的测试服务器上输入我的登录详细信息时,我会被重定向到admin.php
我应该的页面,
但是,当我将文件上传到我的托管服务器并login.php
输入我的登录详细信息时,什么都没有发生,我的意思是页面只是重新加载。我应该admin.php
像在本地主机上测试我的网站时一样被重定向到页面,但在网络服务器上没有任何反应
有谁知道这是为什么?
这是我的代码:
//Open SQL connection
include 'connect.php';
//Check if user has entered Data yet
if(isset($_POST['submit']))
{
//Get values from username and password user entered into form field
$uname = $_POST['name'];
$pword = $_POST['pword'];
//Get username and password from database
$result = mysql_query('SELECT `username`, `password`
FROM player_info
WHERE `position` = "coach" ') or die (mysql_error());
while($row = mysql_fetch_array($result))
{
$username = $row['username'];
$password = $row['password'];
}
//Check if username and password entered matched the username and password stored in the database
if($uname != $username || $pword != $password)
{
echo '<center><p style="color:red">Username and Password incorrect. Please try again</center>';
}
//if username and password match redirect to admin page
else if($uname = $username && $pword == $password)
{
echo("<script>location.href ='admin.php'</script>");
session_start();
$_SESSION[$pword];
$_SESSION['username'] = $username;
}
}
echo'<ul>';
echo'<li><a href="login.txt"><b>Source Code</a>';
echo'</ul>';
//Login Form
echo'<form name="test" action="" method="post">';
echo'<div align="center">';
echo '<form name="login" method="post" action="">';
echo'<input type="text" name="name">'; echo'<input type="password" name="pword">';
echo '<input type="submit" name="submit">';
echo '</form>';
echo '<h2>Welcome to the Scoregasims rugby club</h2>';
echo '<img src="images/logo.jpg">';
echo'</div>';
echo'
</body>
</html>';
?>
PS我知道这段代码对sqlinjections不安全,但我还没有学习。