Error Display

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php14user
Forum Newbie
Posts: 12
Joined: Tue Apr 08, 2008 11:02 pm

Error Display

Post by php14user »

Hi,

There is a Login Page/form which when submitted invokes a php file "get_valid_user.php".
If the user is not valid then "get_valid_user.php" echoes the message that "Invalid/Incorrect Username or Password".
My requirement is to display this error message inside a particular cell (Row3-Col1) of the table as shown in the attached file.

How do we do this?

Thanks.
Attachments
untitled.GIF
untitled.GIF (2.97 KiB) Viewed 165 times
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Error Display

Post by aceconcepts »

Use an if statement to display and addition row and colspan
php14user
Forum Newbie
Posts: 12
Joined: Tue Apr 08, 2008 11:02 pm

Re: Error Display

Post by php14user »

aceconcepts wrote:Use an if statement to display and addition row and colspan
But let's say the row is already there and I just need to display the error inside the first cell of 3rd Row.
Is it possible?

Thanks,
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Error Display

Post by onion2k »

php14user wrote:Is it possible?
Have you tried to do it?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Error Display

Post by aceconcepts »

Sure, just check if there is an error and echo a message.
php14user
Forum Newbie
Posts: 12
Joined: Tue Apr 08, 2008 11:02 pm

Re: Error Display

Post by php14user »

aceconcepts wrote:Sure, just check if there is an error and echo a message.
I am not sure what to do actually...
When I open login page, table gets created as shown in the attachment of my first mail.
The Last row is kept empty to fill the error message if invalid user tries to log in.
I would like to display the error message in the 3rd Row (colspan =4).
I am using another php file "get_valid_user.php" to validate the user and echo the message onto Login Page inside the specified cell.

Please help.

Thanks
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Error Display

Post by aceconcepts »

What you could do to make life simple is set the form action="".

At the top of your first page include the validation file

e.g.

Code: Select all

 
//PAGE 1
 
//check if the form has been submitted - if so then call the validation script
if(isset($_POST['submitForm']))
{
   include("get_valid_user.php");
}
 
//display the form
<form method="post" action="">
   //input fields
 
   //if error exists then display it
      if($loginErr==1)
      {
         echo'Invalid username and/or password';
      }
 
   //submitForm button
</form>
 
 
//Page 2 - this will be your validation script
 
$loginErr=0;
 
//if login is incorrect then $loginErr=1;
 
Pretty crude but hope it helps
Post Reply