我正在为客户开发一个项目,但我在重定向到其成员页面时遇到问题。我相信我已经设置了正确的重定向,但它保持重定向回到同一页面,没有错误。是否有人能够帮我解决这个问题。
<?php
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
include ( "_includes/functions.php");
include ( "_includes/header.php");
session_start();
if (isset($_POST["action"])) {
// validate user account and set proper permissions
$email= $_POST["email"];
$password = $_POST["password"];
// Connecting, selecting database
$link = mysql_connect(mysql_host, mysql_user, mysql_password)
or die('Could not connect: ' . mysql_error());
mysql_select_db(mysql_db) or die('Could not select database');
// Performing SQL query
$query = "SELECT * FROM v_clients_members WHERE email='$email'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
$msg = '<span class="txtError">Incorrect email, please try again.</span>';
} else {
//get and then set the membership id
$temp = mysql_fetch_array($result);
//print_r($temp);
$memId = $temp['membership_id'];
//check if person already has logged in before
$query = "SELECT * FROM v_client_member_login WHERE membership_id='$memId' AND is_active=1";
$result = mysql_query($query) or die('Query failed 1:' . mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows == 0){
//if no then insert the password as their new password, and start session
echo $query = "INSERT INTO v_client_member_login (id,membership_id,email,password,is_active,receive_email) VALUES ('','$memId','$email','$password',1,1)";
$result = mysql_query($query) or die('Query failed 2:' . mysql_error());
$_SESSION['is_admin'] = True;
$_SESSION['member_id'] = $memId;
ini_set(’session.gc_maxlifetime’, 60*60);
//header('Location: /members/index.php');
}else{
$temp = mysql_fetch_array($result);
$retEmail = $temp['email'];
$retPass = $temp['password'];
if($email != $retEmail || $password != $retPass){
//email and/or password are the same as the database ones
$msg = '<span class="txtError">Incorrect login, please try again.</span>';
}else{
//just start a session
$_SESSION['is_admin'] = True;
$_SESSION['member_id'] = $memId;
ini_set(’session.gc_maxlifetime’, 60*60);
//header('Location: /members/index.php');
}
}
if(isset($_SESSION['is_admin'])) header('Location: /members/edit.php');
}
// Closing connection
mysql_close($link);
} else {
$msg = '<span class="txtNormal">Please login:</span>';
}
?>
<form action="login.php" method="post" style="margin:0px">
<div align="center">
<table cellpadding="0" cellspacing="0" border="0" style="border: 4px solid #0066CC">
<tr>
<td width="300" height="25" align="center"><span class="txtLogin"><strong>Member Login</strong></span></td>
</tr>
<?php if(isset($msg)){ ?>
<tr>
<td width="300" height="50" align="center"><?php echo $msg;?></td>
</tr>
<?php } ?>
<tr>
<td width="300" align="center" valign="top">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="150" align="left"><span class="txtNormal"><strong>Email</strong></span><br>
<input type="text" id="email" name="email" style="width:150px"></td>
</tr>
<tr>
<td width="150" align="left"><span class="txtNormal"><strong>Password</strong></span><br>
<input type="password" name="password" style="width:150px"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="300" height="50" align="center"><input type="submit" name="action" value="Login"></td>
</tr>
</table>
</div>
</form>
<? include ( "_includes/footer.php"); ?>