467,917 Members | 1,397 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,917 developers. It's quick & easy.

after include login.php in homepage, the print message cant display in homepage

100+
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">
/* clsForgotPassword */
a.clsForgotPassword:link {color: #0000FF}
a.clsForgotPassword:visited {color: #0000FF}
a.clsForgotPassword:hover {color: #000099}
a.clsForgotPassword:active {color: #000099}
a.clsRegister:link {color: #0000FF}
a.clsRegister:visited {color: #0000FF}
a.clsRegister:hover {color: #000099}
a.clsRegister:active {color: #000099}
</style>
</head>

<?
$conn=mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db("ums e-job portal", $conn) or die(mysql_error());

$_SESSION['loggedin'] = 0;

$result = mysql_query("SELECT * FROM alumni WHERE username='{$_POST['username']}' AND password='{$_POST['password']}'")
or die(mysql_error());

$row = mysql_fetch_array( $result ); //okay

if (isset($_POST['submit'])){

if ((!empty ($_POST['username']))&&(!empty($_POST['password'])) ){//no forgot field

if($row['username'] == ''){
print '<p><strong>Invalid 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><strong>Please make sure you enter both <br />username and password!</strong></p>';
}

}
?>[/PHP]

[HTML]<form action="alumniLogin.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="#BA5179">
<td width> <center>
<font color="#FFFFFF" size="3" face="Verdana"><strong>ALUMNI LOGIN</strong></font> </center>
</td>
</tr>
<tr bgcolor="#FFD7E6">
<td width><font size="2" face="Verdana"><strong>&nbsp;&nbsp;&nbsp;Username</strong></font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td width><font size="2" face="Verdana">&nbsp;
<input type="text" name="username" size="24">&nbsp;
</font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td><font size="2" face="Verdana"><strong>&nbsp;&nbsp;&nbsp;Password</strong></font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td><font size="2" face="Verdana">&nbsp;
<input type="password" name="password" size="24">&nbsp;
</font></td>
</tr>
<tr bgcolor="#FFD7E6"><td colspan="2"><font size="2" face="Verdana">&nbsp;
<input type="submit" name="submit" value="Login">
</font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td colspan="2">&nbsp;&nbsp;&nbsp;<a href="forgotPassword.php" class="clsForgotPassword"><font size="1.8" face="Verdana">Forgot
password?</font></a></td>
</tr>
<tr bgcolor="#FFD7E6">
<td colspan="2"><font size="1.8" face="Verdana">&nbsp;&nbsp;&nbsp;Not Register Yet? <br>&nbsp;&nbsp;&nbsp;<a href="alumniRegister.php" class="clsRegister">Register
Now!</a></font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td colspan>&nbsp;</td>
</tr>
</table>
</form>[/HTML]
Mar 2 '07 #1
  • viewed: 2741
Share:
3 Replies
ronverdonk
Expert 4TB
Pass the error indicator to the home page. You can do that by invoking the home page (using the header() function) and passing the error indicator in the url.

Something like [php]header('Location: homepage.php?showerror=1');[/php]
Your home page then must check for the error trigger set in the $_GET array and print the message, like:
[php]
if (isset($_GET['showerror']) AND $_GET['showerror'] == 1) {
print'<p><strong>Please make sure you enter both <br />username and password!</strong></p>';
}[/php]

Ronald :cool:
Mar 2 '07 #2
100+
Pass the error indicator to the home page. You can do that by invoking the home page (using the header() function) and passing the error indicator in the url.

Something like [php]header('Location: homepage.php?showerror=1');[/php]
Your home page then must check for the error trigger set in the $_GET array and print the message, like:
[php]
if (isset($_GET['showerror']) AND $_GET['showerror'] == 1) {
print'<p><strong>Please make sure you enter both <br />username and password!</strong></p>';
}[/php]

Ronald :cool:
Thanks... It work for me...
But if i want the pop up window for the users when they don't enter the username or password or they insert invalid username or password, is it need to use javascript??
how to code it??? Thanks.. :)
Mar 2 '07 #3
ronverdonk
Expert 4TB
Your question (and thread title) was to display it at the home page. Are you telling me that that was wrong and now you want it as a popup screen?

If so, start developing some of the JS code and we will have a look at it when you envounter errors.

Ronald :cool:
Mar 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Bartosz Wegrzyn | last post: by
10 posts views Thread by Robert | last post: by
1 post views Thread by sharp2037 | last post: by
1 post views Thread by amiri.arash | last post: by
bartonc
reply views Thread by bartonc | last post: by
11 posts views Thread by cwhite | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.