Simple Form Validation using php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?php if(isset($_POST['submit'])) { //accesing the user entered details $username=trim($_POST['name']); //trim function is using for remove the spaces from the start and end of the string where customers entered. $email=trim($_POST['email']); $phone=trim($_POST['phone']); if(empty($username) && empty($email)) { echo "All fields are compulsory"; } else { header("Location: test.php"); } } ?> <html> <head> <title>Simple Contact Form</title> </head> <body> <form id="myform1" method="post" action="test.php"> <br /> Employee Name : <input type="text" name="name" value="" /> <br /> Email : <input type="text" name="email" value="" /> <br /> Phone : <input type="text" name="phone" value="" /> <br /> <p><input type="submit" name="submit" class="button" value="Submit" /></p> </form> </body> </html> |