hey guys, so i have already completed the form and the validation. what i wanna know is how to retain the values that user has already types into the text boxes.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;" charset="iso-8859-1;">
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen">
</head>
<body>
<center><img class="banner" src="image/banner.jpg"></center>
<div class="button">
<div class="bcontent">
<ul class="menu">
<li class="nvg"><a class="nav" href="index.php">Home</a></li>
<li class="nvg"><a class="nav" href="">About</a></li>
</ul>
</div>
</div>
<center>
<div class="slabel"><center><font face="Malgun Gothic" size="5" color="white"><b><label>Sign Up</label></b></font></center></div>
<div class="fsignup"><form name="register" action="register.php" method="POST">
<table style="margin-left:10px; padding-top:10px;">
<tr><td><font color="White" face="Malgun Gothic"><b>Full Name :</b></td>
<td><input type="text" maxlength="50" size="30" name="name" placeholder="Noreen Nong Musa" value="<?=@$name?>" /><br>
</tr>
<tr>
<td style="padding-top:10px;"><font color="White" face="Malgun Gothic"><b>Email :</font></b></td>
<td style="padding-top:10px;"><input type="text" maxlength="30" size="20" name="email" placeholder="example@example.com" value="<?=@$email ?>" /></td>
</tr>
<tr>
<td style="padding-top:10px;"><font color="White" face="Malgun Gothic"><b>Password :</font></b></td>
<td style="padding-top:10px;"><input type="password" maxlength="10" size="20" name="password" placeholder="Password" required /><br></td>
</tr>
<tr>
<td style="padding-top:10px;"><font color="White" face="Malgun Gothic"><b>Confirm Password :</font></b></td>
<td style="padding-top:10px;"><input type="password" maxlength="10" size="20" name="cpassword" placeholder="Confirm Password" required /><br></td>
</tr>
</table>
<div style="text-align:center; margin-top:50px;">
<input type="submit" class="signup" value="Sign Up" name="submit">
</div>
</form></div>
</center>
</body>
</html>
<?php
if (isset($_POST['submit']))
{
$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);
$cpassword = mysql_real_escape_string($_POST['cpassword']);
if(strlen($name)>10)
{
require "connect.php";
$checkname=@mysql_query("SELECT `name` FROM `register` WHERE `name` = '$name' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($checkname)>0)
{
echo ('<script>alert("Name already exists")</script>');
}
else
{
if(strlen($email)<55)
{
require "connect.php";
$checkemail=@mysql_query("SELECT `email` FROM `register` WHERE `email` = '$email' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($checkemail)>0)
{
echo ('<script>alert("Email already exists")</script>');
}
else
{
if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $email))
{
if(preg_match('/^(?=.*\d).{4,10}$/', $password))
{
if($password == $cpassword)
{
require "connect.php";
$query= mysql_query("INSERT INTO register(name,email,password) VALUES ('$name','$email','$password')");
if($query)
{
echo ('<script type="text/javascript">alert("Registration is Successful");
window.location = "index.php"</script>');
}
else
{
echo ('<script type="text/javascript">alert("Registration is Unsuccessful");
window.location = "register.php"</script>');
}
}
else
{
echo "Passwords do not match!";
}
}
else
{
echo "Password must be between 4 and 8 digits long and include at least one numeric digit.";
}
}
else
{
echo "Email address is invalid";
}
}
}
else
{
echo "Email address is too long";
}
}
}
else
{
echo "Name is too short";
}
}
exit();
?>
for example in the email field, the email given by user is invalid so the error message will appear but the name field would still be retained with the name given by user. how do i accomplish that? as u can see ive tried using <?=@$name?>
and also <?php echo $name?>
but those didnt work. And i dont wanna use javascript because well what if the user has javascrit turned off then no validation will happen and also im keepping to languages i know coz my deadline is tmr. This validation part where the values are retained is just a last minute addition. thanks in advance for any help!