I want to display the error message below the text box for example in the Username and password text box i didnt enter any thing means the message Enter the Username and Enter the password wants to display below the Username and password textbox respectively can anybody knows the script for this
not necessarily. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> </head> <body> <form action="<?=$_SERVER['PHP_SELF'];?>" method="post"> <p> <label for="username">username: </label> <input type="text" size="30" value="username" name="username" id="username" /> </p> <p> <label for="password">password: </label> <input type="password" size="30" value="password" name="password" id="password" /> </p> <p> <input type="submit" value="login" name="submit" /> </p> </form> <?php if ( isset($_POST['username']) && isset($_POST['password']) ) { if ( $_POST['username'] == "test" && $_POST['password'] == "test" ) { ?> <h2>Redirecting you to the member page</h2> <?php } else { ?> <h2 style="color:red;">Incorrect username and or password</h2> <? } } ?> </body> </html> PHP:
even then all you would need is a simple $_GET[] to determine if the user has showd up here in error. they goto the processing page after logging in, on an invalid pass they get sent back to login.php?q=e or something and voila, error.