co.ador Posted January 6, 2010 Share Posted January 6, 2010 <div id="tresuno"> <p>Contac us we want to assist you better.....</p> <div id="tresdos"> <form action="step2.php" method="post"> Name<br/><input name="username" type="text" id="username" /> <br/> Email<br/><input name="email" type="text" id="email"/> <br/> Message<br/><textarea name="message" cols="60" rows="8" id="message"></textarea> <br/> <input type="submit" value="Send your message" /><br/> </form> </div> </div> Link to comment https://forums.phpfreaks.com/topic/187377-how-can-i-validate-this-simple-contact-us-form/ Share on other sites More sharing options...
PravinS Posted January 6, 2010 Share Posted January 6, 2010 You can use javascript validation Link to comment https://forums.phpfreaks.com/topic/187377-how-can-i-validate-this-simple-contact-us-form/#findComment-989462 Share on other sites More sharing options...
co.ador Posted January 6, 2010 Author Share Posted January 6, 2010 Does anyone has a starting point on where to star to validate this form? where to go, what do do? Link to comment https://forums.phpfreaks.com/topic/187377-how-can-i-validate-this-simple-contact-us-form/#findComment-989472 Share on other sites More sharing options...
Shocker88 Posted January 6, 2010 Share Posted January 6, 2010 As pbs said above, best to do this validation in javascript (using a library such as jQuery may help). The only thing you'd really want to check server-side (in the php) in a simple contact form such as that, is whether the required fields are filled in. ie. if you wanted to make sure they entered a name in: if ($_POST['username'] == '') { echo 'Please make sure you enter a username before submitting the form.'; } else { // process results } You could get more specific on which values they can enter in what field but that would require regex which is far more complex if you are new to validation. Link to comment https://forums.phpfreaks.com/topic/187377-how-can-i-validate-this-simple-contact-us-form/#findComment-989474 Share on other sites More sharing options...
co.ador Posted January 6, 2010 Author Share Posted January 6, 2010 The above script will check weather username is equal to empty then, echo enter and input in the username input, let say. Is there another way of checking a different posibility? Let say if the type of form being validated is retrieving information from a database instead of sending information Then I would say there is a possibility of checking weather a input is NULL meaning it doesn't match any of the record in the database. so the testing would be weather the index username is NULL instead of empty right? Link to comment https://forums.phpfreaks.com/topic/187377-how-can-i-validate-this-simple-contact-us-form/#findComment-989718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.