[英]an empty page when the user enter wrong info in check log in
I've this code to check the information that the user entered to log in , when the info are correct it supposed to show the next page , it its not it suppose to show a page that said "Not found user" the thing is this code was working fine after uploading my website , but i was getting this error : 我有这段代码来检查用户输入的登录信息,当信息正确时,它应该显示下一页,而不是应该显示一个显示“未找到用户”的页面,这是不是上传我的网站后,代码工作正常,但出现此错误:
[18-May-2012 15:07:31] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started ....)
" [18-May-2012 15:07:31] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started ....)
and as I was searching I knew that this happened cause some output before the session , so I fixed it , but just when I fixed and I enter a wrong info it shows only blank page !! 当我正在搜索时,我知道这会在会话之前引起一些输出,因此我将其修复,但是当我修复并输入错误的信息时,它仅显示空白页面! any help would be appreciated this is the code :
任何帮助将不胜感激,这是代码:
<?php
ob_start();
session_start();
include("adBanner.html");
echo "<br />
<br />
<br />
<br />
<br />
<br />
";
// Connect to server and select databse.
$con = mysql_connect('localhost', 'root', 'pass')or die("cannot connect");
$sel = mysql_select_db('drsaada1_iexa',$con)or die("cannot select DB");
// username and password sent from form
$myusername = addslashes(strip_tags($_POST['myusername']));
$mypassword = addslashes(strip_tags($_POST['mypassword']));
if ($myusername && $mypassword){
$finduser = mysql_query("SELECT * FROM instructor WHERE Name='".$myusername."' and Password='".$mypassword."'")
or die ("mysql error");
if (mysql_num_rows($finduser)!=0){
while ($row = mysql_fetch_assoc($finduser)){
$uname = stripcslashes($row['Name']);
$upass = stripcslashes($row['Password']);
}
if ($myusername == $uname AND $mypassword == $upass){
$_SESSION['sessionname']= $uname ;
$_SESSION['sessionpass']= $upass ;
echo '<h3>Welcome '.$uname.' To iExamination System</h3> <br />
<a href="Instructor.htm"><h2>Go To Instructor Page</h2></a>
';
}
}
//////////
$findadmin = mysql_query("SELECT * FROM admin WHERE Username='".$myusername."' and Password='".$mypassword."'")
or die ("mysql error");
if (mysql_num_rows($findadmin)!=0){
while ($row = mysql_fetch_assoc($findadmin)){
$iname = stripcslashes($row['Username']);
$ipass = stripcslashes($row['Password']);
}
if ($myusername == $iname AND $mypassword == $ipass){
$_SESSION['sessionna']= $iname ;
$_SESSION['sessionpa']= $ipass ;
echo '<h3>Welcome '.$iname.' To iExamination System</h3> <br />
<a href="admin.htm">Go To Adminstrator Page</a>
';
}
}
}else {
die ("Not Fouund User Or Page ");
}
mysql_close($con);
ob_end_flush();
?>
You die inside a buffer so no output will ever be seen. 您死在缓冲区内,因此将看不到任何输出。 If you are going to die you need to ob_end_clean() the buffer first.
如果您要死亡,则需要先ob_end_clean()缓冲区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.