i have this registration form but what i need to do is make some of the fields required such as name username password and email also to check if the email is valid can any one advise me thanks Doug <title>Register</title> </head> <body bgcolor="#FF0000"> <form action="insert.php" method="post"> <table border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td><h3 style="border-bottom:1px solid black;">Registration Form</h3></td> </tr> <tr> <td> <label for="name" style="float:left;width:140px;">Name:</label><input type="text" name="name" id="name" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div> <label for="username" style="float:left;width:140px;">Username</label><input type="text" name="username" id="username" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div> <label for="password" style="float:left;width:140px;">Password</label><input type="password" name="password" id="password" value="" maxlength="" style="width:200px;"> <div style="clear:left;height:20px;"> </div> <label for="email" style="float:left;width:140px;">E-Mail Address:</label><input type="text" name="email" id="email" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div> <label for="parkname" style="float:left;width:140px;">Caravan Park Name</label><input type="text" name="parkname" id="parkname" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div> <label for="parklocation" style="float:left;width:140px;">Park Location</label><input type="text" name="parklocation" id="parklocation" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div> <label for="caravandetails" style="float:left;width:140px;">Caravan Details</label><textarea name="caravandetails" id="caravandetails" style="width:200px;height:100px;"></textarea><div style="clear:left;height:20px;"> </div> </td> <tr> <td align="right"> <!-- YOU CAN MODIFY THE TEXT WITHIN VALUE="" TO MODIFY YOUR BUTTON TEXT--> <input type="submit" value=" Register "> <input type="reset" value=" Reset "> </td> </tr> </table> </form> PHP:
Have a look at this link, it explains how to do form validation via Javascript, which is your best option - it means instantaneous validation rather than waiting for a submit. http://www.w3schools.com/js/js_form_validation.asp
As well as give check in insert.php Suppose you want username mandatory if($_POST['username'] != '') { // Register } Otherwise user can disable javascript and registered in your site without the username.
ok tried the javascript and that didnt work i put an email address that was wrong but it still inserted it i put instead of .co.uk tried to email with hot mail to blueyonder.com and came back as no delivery cheers Doug
Hey, The script wasn't meant to do that - it was just meant to check the FORMAT of the field. - i.e. make sure it was You can't realistically verify if an email address is correct. There are a number of methods you can use such as connect to the MX for the domain specified which will eliminate some level of error, but nothing definitive. Usually not worth the effort to do - using your example, the validation would have still passed because blueyonder.com is a valid domain, even though your email account isn't hosted there. But basically, thats why sites send you a verification email that you have to click to open your account when you register - because they can't definitely check themselves if your email account exists.