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> Username</strong></font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td width><font size="2" face="Verdana">
<input type="text" name="username" size="24">
</font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td><font size="2" face="Verdana"><strong> Password</strong></font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td><font size="2" face="Verdana">
<input type="password" name="password" size="24">
</font></td>
</tr>
<tr bgcolor="#FFD7E6"><td colspan="2"><font size="2" face="Verdana">
<input type="submit" name="submit" value="Login">
</font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td colspan="2"> <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"> Not Register Yet? <br> <a href="alumniRegister.php" class="clsRegister">Register
Now!</a></font></td>
</tr>
<tr bgcolor="#FFD7E6">
<td colspan> </td>
</tr>
</table>
</form>[/HTML]
3 3180
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:
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.. :)
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:
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bartosz Wegrzyn |
last post by:
Hi,
I have simple web with authentication.
My main page looks like this:
<?php
include ("nav.htm");
include ("auth.php");
$menu = $_GET;
|
by: Ram |
last post by:
I have a start page for my application default.htm which contains four
frames.
header.htm
login.aspx
rightside.htm
footer.htm
login.aspx conatins username, password fields and login button....
|
by: Robert |
last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into
some sporadic viewstate errors...usually saying the viewstate is invalid,
eventvalidation failed or mac error.
My web...
|
by: sharp2037 |
last post by:
Hi Everyone,
I am working on an ASP.net application and I have a homepage to which
everyone visits of course and on that front page I have a user ID and
password box and a login button.
What...
|
by: amiri.arash |
last post by:
Hi!
I want to feed the news section of my band - homepage with the mySpace
blog of our band (in order to keep redundancy low).
The band homepage is written in PHP.
I wrote an xsl-stylesheet...
| |
by: libra786 |
last post by:
I have created a blog and have added a login box which prompts the user for login and id before posting- The username and password have been stored in the database, however when i enter the username...
|
by: bartonc |
last post by:
from MySQLdb import *
from time import time
class DBServer:
def __init__(self, master):
self.master = master
def Login(self, servername, username, password): #,...
|
by: bartonc |
last post by:
With one small change to the view/control:
self.staticText3 = wx.StaticText(id=wxID_DBCONNECTDIALOGSTATICTEXT3,
label='ODBC Data Source Name', name='staticText3',...
|
by: cwhite |
last post by:
i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3
mysql 4.1 and apache 2.0.52, and all of the php scripts i had which
called specific entries from mysql are no longer working
if...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| | |