Look at this Script. It may help you some what. If you have any question about it, you are welcome!!!!!!
<body>
<H1><center>REGISTRATION FORM</H1><hr>
<h2>Please insert your details!</h2>
<h2>All text fields must be completed, before submitting!</h2>
<?
function CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno)
{
echo "<form method=post action= wrong.php><br>";
echo "Username: <input type=Text name=username value=$username><center><br>";
echo "Password: <input type=password name=password><center><br>";
echo "First name: <input type=Text name=first value=$first><center><br>";
echo "Last name: <input type=Text name=last value=$last><center><br>";
echo "Address: <input type=Text name=address value=$address><center><br>";
echo "Postcode: <input type=Text name=postcode value=$postcode><center><br>";
echo "Country: <input type=Text name=country value=$country><center><br>";
echo "Email Address: <input type=Text name=email value0$email><center><br>";
echo "Tel No: <input type=Text name=telno value=$telno><center><br><br>";
echo "<input type=Submit name=submit value='SUBMIT FORM'>";
echo "</form>";
}
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
if (isset($submit)) {
if($username == "" or $password == "" or $first == "" or $last == "" or $address == "" or
$postcode == "" or $country == "" or $email == "" or $telno == "") {
echo "<h2><font color=red>Please enter all necessary Information!!! </font></h2>";
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
}
else if(!eregi("[a-zA-Z0-9_-]+@[a-zA-Z0-9-_]+.[a-zA-Z0-9-.]+$", $email))
{
echo "<h2><font color='red'>Please enter Valid Email Address";
echo "</font></h2>";
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
}
else if(!eregi("[0-9-]", $telno))
{
echo "<h2><font color='red'>Please enter Valid Telephone ";
echo "Number</font></h2>";
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
}
else if(!eregi("[A-Za-z]", $first))
{
echo "<h2><font color='red'>Please enter Valid First Name</font></h2>";
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
}
else if(!eregi("[A-Za-z]", $last))
{
echo "<h2><font color='red'>Please enter Valid Last Name</font></h2>";
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
}
// you can continue controlling the other fields like this if you want.....
else {
// check weather a username and password are already in your database or not
$db = mysql_connect("localhost", "root");
mysql_select_db("Football",$db);
$query = "select * from members where username like '$username' and password like '$password'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if($count > 0) { // it is already in the database & display the form to choose another un & pw
echo "This user name is already chosen by somebody, please enter another.....";
CreateForm($username, $password, $first, $last, $last, $address, $postcode, $country, $email, $telno);
}
else {
$db = mysql_connect("localhost", "root");
mysql_select_db("Football",$db);
$sql = "INSERT INTO members (username,password,firstname,lastname,address,postcode,country,emailaddress,telno) VALUES ('$username','$password','first','$last','$address','$postcode','$country','$emailaddress','$telno')";
$result = mysql_query($sql);
echo "THANK YOU!\n";
echo "YOUR DETAILS HAVE BEEN SUCCESSFULLY SUBMITTED! YOU ARE NOW A MEMBER\n <br><br><a href =\"main.php\">BACK TO MAIN PAGE</a> </body>";
exit;
}
}
}
?>
<a href ="main.php">BACK TO MAIN PAGE</a>