当我执行需要登录用户的操作时,我有时必须重新登录。大部分时间都是在我第一次登录时发生的。注销后,我无法重新创建该问题。
谁知道出了什么问题?
在索引页面的顶部,我有session_start(); 在索引页面中,我已包含所有其他页面。
登录页面:
function login_form()
{
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$qLogin = mysql_query("SELECT G_id FROM users WHERE
G_name = '".mysql_real_escape_string($_POST['G_name'])."' AND
password = '".sha1($_POST['password'])."'");
$qActivatie = mysql_query("SELECT COUNT(G_id) FROM users, user_activaties WHERE
users.G_name = '".mysql_real_escape_string($_POST['G_name'])."' AND
users.G_id = users_activaties.users_id");
if(mysql_result($qActivatie,0) != 0) {
echo 'account not activated.';
} elseif(mysql_num_rows($qLogin) == 0) {
echo 'user name/password is not correct.';
} else {
$_SESSION['user'] = mysql_result($qLogin, 0);
$_SESSION['G_name'] = $_POST['G_name'];
header("Location: index.php?func=panel ");
?>
Succesfull logged in.<a href="controlpanel.php">Click</a>
<?php
}
}
?>
<div id="login">
<form action="<?=htmlentities($_SERVER['REQUEST_URI'])?>" method="post">
<input type="text" name="G_name" placeholder="User"/>
<input type="password" name="Password" placeholder="Password"/>
<button type="submit">Login</button>
</form>
</div>
<?php
}
有时需要重新登录的操作
session_start();
include("db.php");
$O_id=$_GET['O_id'];
$G_id=$_GET['G_id'];
$G_name=$_GET['G_name'];
$aanwezig=$_GET['aanwezig'];
$query = mysql_query
("INSERT INTO koppeltabel(O_id, G_id, aanwezig)
VALUES ('$O_id','$G_id', '$aanwezig')
ON DUPLICATE KEY
UPDATE aanwezig='$aanwezig' ");
mysql_query($query);
header('Location: http://www.abc.nl/new/index.php?func=option');