Below is my login function, it can work well, but after i include it at my homepage, the print message is in the login page...
What should it do to make the print message invalid username or password and please enter you enter both username and password display in homepage, please help me...
[PHP]<?php
ob_start();
session_start() ;
?>
<html>
<head>
<style type="text/css">
/* clsForgotPasswo rd */
a.clsForgotPass word:link {color: #0000FF}
a.clsForgotPass word:visited {color: #0000FF}
a.clsForgotPass word:hover {color: #000099}
a.clsForgotPass word:active {color: #000099}
a.clsRegister:l ink {color: #0000FF}
a.clsRegister:v isited {color: #0000FF}
a.clsRegister:h over {color: #000099}
a.clsRegister:a ctive {color: #000099}
</style>
</head>
<?
$conn=mysql_con nect("localhost ", "root", "") or die (mysql_error()) ;
mysql_select_db ("ums e-job portal", $conn) or die(mysql_error ());
$_SESSION['loggedin'] = 0;
$result = mysql_query("SE LECT * FROM alumni WHERE username='{$_PO ST['username']}' AND password='{$_PO ST['password']}'")
or die(mysql_error ());
$row = mysql_fetch_arr ay( $result ); //okay
if (isset($_POST['submit'])){
if ((!empty ($_POST['username']))&&(!empty($_P OST['password'])) ){//no forgot field
if($row['username'] == ''){
print '<p><strong>Inv alid username or password.</strong><br />Please try again.</p>';
}else{
$_SESSION['loggedin'] = 1;
$_SESSION['loggedin'] = time();
$_SESSION['username'] = $row['username'];
$_SESSION['company_ID'] = $row['company_ID'];
header ('Location: welcome.php');
exit();
}
}else{//Forgot a field.
print'<p><stron g>Please make sure you enter both <br />username and password!</strong></p>';
}
}
?>[/PHP]
[HTML]<form action="alumniL ogin.php" method="POST">
<TABLE width="166" cellPadding=0 cellSpacing=0 bgcolor=#8870AB style="BORDER-RIGHT: #9B77CB 1px double; PADDING-RIGHT: 0px; BORDER-TOP: #9B77CB 1px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #9B77CB 1px double; WIDTH: 140px; COLOR: #000000; PADDING-TOP: 0px; BORDER-BOTTOM: #9B77CB 1px double; FONT-STYLE: normal; FONT-FAMILY: Verdana; TEXT-DECORATION: none" >
<tr align="center" bgcolor="#BA517 9">
<td width> <center>
<font color="#FFFFFF" size="3" face="Verdana"> <strong>ALUMN I LOGIN</strong></font> </center>
</td>
</tr>
<tr bgcolor="#FFD7E 6">
<td width><font size="2" face="Verdana"> <strong> & nbsp; User name</strong></font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td width><font size="2" face="Verdana">
<input type="text" name="username" size="24">  ;
</font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td><font size="2" face="Verdana"> <strong> & nbsp; Pass word</strong></font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td><font size="2" face="Verdana">
<input type="password" name="password" size="24">  ;
</font></td>
</tr>
<tr bgcolor="#FFD7E 6"><td colspan="2"><fo nt size="2" face="Verdana">
<input type="submit" name="submit" value="Login">
</font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td colspan="2">&nb sp; <a href="forgotPas sword.php" class="clsForgo tPassword"><fon t size="1.8" face="Verdana"> Forgot
password?</font></a></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td colspan="2"><fo nt size="1.8" face="Verdana"> &nb sp;Not Register Yet? <br>   ; <a href="alumniReg ister.php" class="clsRegis ter">Register
Now!</a></font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td colspan> </td>
</tr>
</table>
</form>[/HTML]
What should it do to make the print message invalid username or password and please enter you enter both username and password display in homepage, please help me...
[PHP]<?php
ob_start();
session_start() ;
?>
<html>
<head>
<style type="text/css">
/* clsForgotPasswo rd */
a.clsForgotPass word:link {color: #0000FF}
a.clsForgotPass word:visited {color: #0000FF}
a.clsForgotPass word:hover {color: #000099}
a.clsForgotPass word:active {color: #000099}
a.clsRegister:l ink {color: #0000FF}
a.clsRegister:v isited {color: #0000FF}
a.clsRegister:h over {color: #000099}
a.clsRegister:a ctive {color: #000099}
</style>
</head>
<?
$conn=mysql_con nect("localhost ", "root", "") or die (mysql_error()) ;
mysql_select_db ("ums e-job portal", $conn) or die(mysql_error ());
$_SESSION['loggedin'] = 0;
$result = mysql_query("SE LECT * FROM alumni WHERE username='{$_PO ST['username']}' AND password='{$_PO ST['password']}'")
or die(mysql_error ());
$row = mysql_fetch_arr ay( $result ); //okay
if (isset($_POST['submit'])){
if ((!empty ($_POST['username']))&&(!empty($_P OST['password'])) ){//no forgot field
if($row['username'] == ''){
print '<p><strong>Inv alid username or password.</strong><br />Please try again.</p>';
}else{
$_SESSION['loggedin'] = 1;
$_SESSION['loggedin'] = time();
$_SESSION['username'] = $row['username'];
$_SESSION['company_ID'] = $row['company_ID'];
header ('Location: welcome.php');
exit();
}
}else{//Forgot a field.
print'<p><stron g>Please make sure you enter both <br />username and password!</strong></p>';
}
}
?>[/PHP]
[HTML]<form action="alumniL ogin.php" method="POST">
<TABLE width="166" cellPadding=0 cellSpacing=0 bgcolor=#8870AB style="BORDER-RIGHT: #9B77CB 1px double; PADDING-RIGHT: 0px; BORDER-TOP: #9B77CB 1px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #9B77CB 1px double; WIDTH: 140px; COLOR: #000000; PADDING-TOP: 0px; BORDER-BOTTOM: #9B77CB 1px double; FONT-STYLE: normal; FONT-FAMILY: Verdana; TEXT-DECORATION: none" >
<tr align="center" bgcolor="#BA517 9">
<td width> <center>
<font color="#FFFFFF" size="3" face="Verdana"> <strong>ALUMN I LOGIN</strong></font> </center>
</td>
</tr>
<tr bgcolor="#FFD7E 6">
<td width><font size="2" face="Verdana"> <strong> & nbsp; User name</strong></font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td width><font size="2" face="Verdana">
<input type="text" name="username" size="24">  ;
</font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td><font size="2" face="Verdana"> <strong> & nbsp; Pass word</strong></font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td><font size="2" face="Verdana">
<input type="password" name="password" size="24">  ;
</font></td>
</tr>
<tr bgcolor="#FFD7E 6"><td colspan="2"><fo nt size="2" face="Verdana">
<input type="submit" name="submit" value="Login">
</font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td colspan="2">&nb sp; <a href="forgotPas sword.php" class="clsForgo tPassword"><fon t size="1.8" face="Verdana"> Forgot
password?</font></a></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td colspan="2"><fo nt size="1.8" face="Verdana"> &nb sp;Not Register Yet? <br>   ; <a href="alumniReg ister.php" class="clsRegis ter">Register
Now!</a></font></td>
</tr>
<tr bgcolor="#FFD7E 6">
<td colspan> </td>
</tr>
</table>
</form>[/HTML]
Comment