ログインフォームがあるインデックスページからホームページにセッションを引き継ぐようにしようとしていますが、インデックスページに戻り続けています。何が間違っているのかわかりません。両方のページにsession_start()があることを確認します。ひどく助けが必要です、そしてどんな助けでも大いに感謝されます。
index.phpスクリプト:
`<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
if(isset($_COOKIE['loginMemPro']))
{
include_once("Connections/first.php");
$memEmail = $_COOKIE['loginMemPro']['memEmail'];
$password = $_COOKIE['loginMemPro']['log_password'];
$query = "SELECT email, password FROM pro_members WHERE email = '$memEmail' AND
password = '$password'";
$result = mysql_query($query);
if(mysql_num_rows($result))
{
$_SESSION['loggedin'] = 1;
$_SESSION['loginMem'] = $memEmail;
header('Location: http://www.pro.com/home.php');
exit();
}
}
?>
<!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>
<link href="/image/x-con.png" rel="icon" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="userlogin_form" name="userlogin_form" action="login_process.php"
method="post">
<table width="100%">
<tr>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%">
<span id="sprytextfield5">
<span class="textfieldRequiredMsg">A email address is required.</span><span
class="textfieldInvalidFormatMsg">Invalid email address format.</span><br/>
Email
<input name="memEmail" type="text" id="memEmail" value="" size="30" />
</span></td>
<td width="20%"> </td>
<td width="20%"> </td>
</tr>
<tr>
<td> </td>
<td width="20%"> </td>
<td>
<span id="sprylog_password">
<span class="passwordRequiredMsg">A password is required.</span><br/>
Password
<input name="log_password" type="password" id="log_password" value=""
size="30" />
</span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td width="10%"> </td>
<td>
<label for="memberMe">
<input name="memberMe" type="checkbox" id="memberMe" value="setcookie" />
Remember Me</label>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"><input id="submit" type="submit" name="login" value="login" />
</td>
<td align="right"> </td>
<td align="right"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td align="right">
<a id="forgotpw_link_id" class="forgotpw_link" href="">forgot password?</a>
</td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>`
home.phpスクリプト:
`<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/login_auth.php";
include_once($path);?>
<!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">
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/CSS/home_style.css";
include_once($path);?>
<body class="thrColLiq" onload="MM_preloadImages">
<div id="header">
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/header.php";
include_once($path);?>
<!-- end #mainContent -->
</div>
<div id="container">
<div id="sidebar1">
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/leftside_bar.php";
include_once($path);?>
</div>
<div id="sidebar2">
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/rightside_bar.php";
include_once($path);?>
</div>
<!-- This clearing element should immediately follow the #mainContent div in order
to force the #container div to contain all child floats -->
<div id="mainContent">
<!-- end #mainContent -->
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/menu.php";
include_once($path);?>
< /div>
<div id="mainContent2">
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/home_script.php";
include_once($path);?>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
<div id="mainContent3">
<!-- end #mainContent -->
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/footer.php";
include_once($path);?>
</div>
<br class="clearfloat" />
<!-- end #container -->
</div>
</body>
</html>
`
ログインauth.phpスクリプト:
`<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: http://www.pro.com/index.php?error=1');
exit();
}
?>
`
login_process.phpスクリプト:
`<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
include_once("Connections/first.php");
$memEmail = mysql_real_escape_string($_POST['memEmail']);
$password = mysql_real_escape_string($_POST['log_password']);
$time = time();
$check = $_POST['memberMe'];
$query = "SELECT email, password FROM pro_members WHERE email = '$memEmail' AND
password = '$password'";
$result = mysql_query($query);
if(mysql_num_rows($result)) {
$_SESSION['loggedin'] = 1;
$_SESSION['loginMem'] = $memEmail;
if($check) {
setcookie("loginMemPro[memEmail]", $memEmail, $time + 3600);
setcookie("loginMemPro[log_password]", $password, $time + 3600);
}
header('Location: http://www.pro.com/home.php');
exit();
}
else
{
header('Location: http://www.pro.com/index.php?error=1');
exit();
}
?>`