제출할 때 로그인 양식이 있습니다. 다시 로그인 페이지로 리디렉션됩니다. 어떤 구문 오류도 찾을 수없는 것 같아서 로그인 양식에 필수적인 것을 빠뜨린 것 같습니다. 여기에 코드가 있습니다.로그인 양식 리디렉션 자체에 제출
login.php :
<?
require ('../includes/config.inc.php');
if ($_POST['act'] == "Insert") {
#// Additional security check
$RR = mysql_query("SELECT id from BPLA_adminusers");
if (mysql_num_rows($RR) > 0) {
print "Fatal error: user cannot be inserted - one or more administrators are already present in the database.<a href=login.php>login page</a>";
exit ;
}
$md5_pass = md5($MD5_PREFIX . $_POST['password']);
echo $query = "insert into BPLA_adminusers values (10,'$_POST[username]', '$md5_pass', '20011224', '20020110093458', 1)";
$result = @mysql_query($query);
#// Redirect
Header("Location: login.php");
exit ;
}
$query = "select MAX(id) from BPLA_adminusers";
$result = @mysql_query($query);
while ($row = mysql_fetch_row($result)) {
$id = $row[0] + 1;
}
?>
<?
if($id==1) {
$id=0;
?>
<form name="login" data-ajax="false" action="login.php" method="post">
<span><? print $ERR;?></span>
<label for="<? print "Username";?>"><? print "Username";?></label>
<input type="text" name="username" />
<label for="<? print "Password";?>"><? print "Password";?></label>
<input type="password" name="password" />
<input type="submit" name="action" value="<? echo $MSG_5204;?>">
</form>
<?
} else {
$id=1;
#//
if($_POST[action] == "login") {
if(strlen($_POST[username]) == 0 || strlen($_POST[password]) == 0) {
$ERR = $ERR_047;
} else {
$query = "select * from BPLA_adminusers where username='$_POST[username]' and password='".md5($MD5_PREFIX.$_POST[password])."'";
$res = @mysql_query($query);
if(!$res) {
print "Error: $query<BR>".mysql_error();
exit;
}
if(mysql_num_rows($res) == 0) {
$ERR = $ERR_048;
} else {
$admin = mysql_fetch_array($res);
#// Set sessions vars
$BPLowbidAuction_ADMIN_LOGIN = $admin[id];
$BPLowbidAuction_ADMIN_USER = $admin[username];
$_SESSION["BPLowbidAuction_ADMIN_LOGIN"]=$BPLowbidAuction_ADMIN_LOGIN;
$_SESSION["BPLowbidAuction_ADMIN_USER"]=$BPLowbidAuction_ADMIN_USER;
#// Update last login information for this user
$query = "update BPLA_adminusers set lastlogin='".date("YmdHis")."' where username='$admin[username]'";
$rr = mysql_query($query);
if(!$rr) {
print "Error: $query<BR>".mysql_error();
exit;
}
#// Redirect
print "<SCRIPT Language=Javascript>
parent.location.href='index.php';
</SCRIPT>";
//Header("Location: home.php");
exit;
}
}
}
?>
<? if(!$act || ($act && $ERR)) {
?>
<form name="login" data-ajax="false" action="login.php" method="post">
<span><? print $ERR;?></span>
<label for="<? print "Username";?>"><? print "Username";?></label>
<input type="text" name=username />
<label for="<? print "Password";?>"><? print "Password";?></label>
<INPUT TYPE=password name=password />
<input type="submit" NAME="action" VALUE="login">
</form>
<? }?>
<? }
require("./footer.php");
?>
이 코드는 index.php를 내에 배치되고 있으며이 제출 때 다시을 index.php로 리디렉션하는 경우/다른 문에 사용되고있다.
의 index.php :
<?
require ('../includes/config.inc.php');
include ('bar.php');
if (!empty($_SESSION['BPLowbidAuction_ADMIN_LOGIN'])) {
include ('home.installation.php');
} else {
include ('login.php');
}
?>
문제는 로그인 양식이 처음 리디렉션 있다는 것이다 로그인 폼 코드가 표시됩니다 다시 "index.php에"로하고 "login.php"과에 것처럼 나는 결코 "bar.php"는 단지 머리말이며 페이지의 메뉴와 "home.installation.php"는 실제로 보여지기로되어있는 홈 페이지입니다.
슬래시한다? – Deepak
괜찮습니다. add session_start(); 뒤에 바로 index.php와 login.php 둘 다. – Deepak
무엇인지 확실하지 않습니까 ?? – Deepak