Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Submitting form after validation
04-11-2012, 07:34 AM #1
- Join Date
- Apr 2011
- Thanked 2 Times in 2 Posts
Submitting form after validation
The thing i want to do
If any field is empty -->User will see a message to fill out the field
When both field is filled out and press Submit button --> goes to thankyou.php page
$fname = $_POST['fname'];
$lname = $_POST['lname'];
<form action="thankyou.php" method="POST">
First Name: <input type="text" name='fname'/>
<?php if(empty($fname)) echo "Please provide your First Name";?><br/>
Last Name: <input type="text" name='lname'/>
<?php if(empty($lname)) echo "Please provide your Last Name";?><br/>
<input type="submit" value="submit" /><input type="reset" value="Clear Form"/>
echo "Thank you $fname $lname for your time."
?>App Developer, Front End Designer and Learner at>> Facebook App Development Company - Cygnis Media
04-11-2012, 08:26 AM #2
- Join Date
- Jun 2002
- London, England
- Thanked 2,596 Times in 2,574 Posts
Form validation of the pattern if(empty($fname)) is barely worthy of the name, and virtually useless, as even a single space, an X or a ? will return false, that is pass the validation.
Form validation has been covered a zillion times in this forum - try using the search feature. Come back if you are still having problems.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.