hi, I have this auth form script. Instead on displaying "Wrong Username or Password" on a new screen how can I make it so it simply display it on the same screen so the new user doesn't have to go back to try again?
<?php
// Check whether the [Play...] button was pressed (if it has been pressed
// there will be an entry in the $_POST global array named the same as the
// the button on the form and so the isset() function will return true).
if (isset($_POST['myusername'])) {
// ************************
// *** PROCESS THE FORM ***
// ************************
ob_start();
$host="^^^^^^^^^"; // Host name
$username="^^^^^^^^^"; // Mysql username
$password="^^^^^^^^^"; // Mysql password
$db_name="^^^^^^^^^"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:loginsuccess.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
}
else {
// the play button wasn't set so display the form
// ************************
// *** DISPLAY THE FORM ***
// ************************
// store the name of this script into $formName so that we can set the action
// of the form to itself.
$formName = $_SERVER['SCRIPT_NAME'];
?>
<form name="form1" method="post" action="<?php echo $formName; ?>">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
<?php
}
?>
</body>
</html>