Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-11-2012, 07:34 AM   PM User | #1
kevin619
New Coder

 
Join Date: Apr 2011
Location: California
Posts: 37
Thanks: 0
Thanked 1 Time in 1 Post
kevin619 is an unknown quantity at this point
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


<html>
<head></head>
<body>
<?php
$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"/>

</form>
</body>
</html>


thankyou.php
<?php
echo "Thank you $fname $lname for your time."
?>
kevin619 is offline   Reply With Quote
Old 04-11-2012, 08:26 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:14 PM.


Advertisement
Log in to turn off these ads.