好吧,我正在尝试创建一个简单的登录页面。有没有办法从sql数据库中注销?
我可以成功地做到这一点,但似乎我无法让多台电脑访问该页面。我在我的mysql数据库上创建了多个不同的用户,他们单独凭证进入并查询它的数据,但是只有一台计算机似乎会放入。
我也设置了PHP会话变量包含登录信息。
我简单的问题是:
是否有一个退出的分贝和销毁我的会议或许让其他计算机访问的用户名一个已经完成
后,它可能是会议的方式或数据库登录仍然徘徊在一台正在造成这种情况的计算机?
我知道我的代码是一个烂摊子:
<?php session_start();
include("password.php"); ?>
...
<body>
<div class="main_content">
<?php
$submenarray = array(
'Purpose' => 'purpose.php',
'Leading Self' => 'leadingself.php',
'Leading with Strategy' => 'leadingwithstrategy.php',
'Leading People' => 'leadingpeople.php',
'Leading for Results' => 'leadingforresults.php',
);
insert_header_with_params(0,0,$submenarray);
?>
<div class="content_body">
<div class="description">
<h1 style="margin-left:5%;">
User <span style="color:red"> Login</span>
</h1>
<p></p>
</div>
<?
global $USERS;
global $_SESSION;
$USERS= getUsers("member1","password");
$record;
$max_login_attempts = 3;
if(isset($_POST['password'])){$_SESSION["password"] = $_POST["password"];}
if($_GET["logged"] == "false"){
$_SESSION["logged"] = "";
}
if(isset($_POST['Field1'])){
$record = getRecord($_POST["Field1"],removeUnwantedChar($_POST["Field1"]),$_POST["password"]);}
if ($_POST["ac"]=="log") { /// do after login form is submitted
if ($record[19]==$_POST["password"]) {
$_SESSION["logged"]=$_POST["Field1"];
$sql = "UPDATE `leading_initiatives` SET `Login Attempts`='0'
WHERE `Name`='".$_POST['Field1']."'";
sql_command($sql,removeUnwantedChar($_POST["Field1"]),$_POST["password"]);
} else {
if($record[20] < $max_login_attempts){
setRecord('Login Attempts',$record[20]+1,$record[1],removeUnwantedChar($_POST["Field1"]),$_POST["password"]);
echo '<p style="padding-left:20%;">Incorrect username/password. '.($max_login_attempts-$record[20]).' attempts remaining.</p>';
}else{
echo 'max reached';
}
}
}
$attempts = $record[20];
if($attempts > $max_login_attempts)
$_SESSION["locked_out"] = "true";
if (array_key_exists($_SESSION["logged"],$USERS)) { //// check if user is logged or not
echo "<p style='padding-left:20%;'>Logged in: ".$_SESSION["logged"]."</p>"; //// if user is logged show a message
echo "<a href='http://newsite.com' style='padding-left:20%;'>form</a></br></br>";
}elseif($_SESSION["locked_out"] == "true"){
echo "<script>
window.location.replace('site/max_attempts.php');
</script>";
}
else { //// if not logged show login form
echo '<form id="the_form" name="the_form" action="http://site/login.php" method="post" style="padding-left:20%;">
<input type="hidden" name="ac" value="log">';
echo 'Username: <select id="Field1" name="Field1">
<option value=""></option>
<option value="Admin">Admin</option>
<option value="Anton, Manny">Anton, Manny</option>
</select>';
echo 'Password: <input type="password" name="password" id="password" />';
echo '<input type="submit" value="Login" />';
echo '</form>';
}
if($_GET["logged"] == "false"){
echo "<script>document.forms['the_form']['Field1'].value = ".$_GET["Field1"].";</script>";
}
?>
</div> <!--end content body-->
</div> <!--end the main content div-->
</body>
你能跟我们分享一些代码吗?这里听起来很奇怪。 – 2015-02-06 13:30:00
连接到数据库时,多个用户可以共享相同的凭据。简单来说,这不是数据库上的问题。它看起来像一个更大的问题。你说只有一个用户可以访问你的“db”。这可能是因为你在Web服务器的HTTP管道“功能”上停滞不前。 – 2015-02-06 13:47:04