i have just created a registration form which stores the details in mysql, but i need to program an error message, when a user leaves out a text field blank ie username or password field etc.
can anyone help?
Here is a copy of my script:
<body>
<H1>REGISTRATION FORM</H1>
<hr>
<?php
if ($submit) {
// process form
$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!\n";
} else{
?>
<form method="post" action="<?php echo $PHP_SELF?>">
Username: <input type="Text" name="username"><br>
<br>
Password: <input type="Text" name="password"><br>
<br>
First name: <input type="Text" name="first"><br>
<br>
Last name: <input type="Text" name="last"><br>
<br>
Address: <input type="Text" name="address"><br>
<br>
Postcode: <input type="Text" name="postcode"><br>
<br>
Country: <input type="Text" name="country"><br>
<br>
Email Address: <input type="Text" name="emailaddress"><br>
<br>
Tel No: <input type="Text" name="telno"><br>
<br>
<input type="Submit" name="submit" value="SUBMIT FORM">
</form>
<?php
} // end if
?>
<a href ="main.php">BACK TO MAIN PAGE</a>
</body>