| | #1 |
| Active Warrior Join Date: 2010
Posts: 80
Thanks: 3
Thanked 3 Times in 3 Posts
|
I need some kind of validation to make sure the fields contain date, I get a lot of blank emails. Any ideas on how to do that with this form? <form action="step2.php" method="post"> Name<br/><input type="text" value="" name="username"/> <br/> Email<br/><input type="text" value="" name="email"/> <br/> Inquiry<br/><textarea row="7" cols="30" name="inquiry"></textarea><br/> <input type="submit" value="send your email" name "submit"> </form> |
| Free E-booklet Make At Least $500 Dollars Your First Month On Adsense Get 1 year hosting for $50 Click Here | |
| |
| | #2 |
| HyperActive Warrior War Room Member Join Date: 2009 Location: Vancouver, British Columbia, Canada
Posts: 114
Thanks: 9
Thanked 8 Times in 7 Posts
|
If you're familiar with PHP, do some validation in 'step2.php'. Here's a very simple example: $userName = $_POST['username']; $email = $_POST['email']; if((trim($userName) == ""))) { echo "You must enter a username."; } elseif((trim($email) == ""))) { echo "You must enter an email address."; //I would actually check for a valid email address } If you're not familiar with PHP, use a CAPTCHA if you're receiving spam inquiries. The Official CAPTCHA Site Services like Wufoo or Machform (a self-hosted form creator) allow you to create forms easily with validation options you can select. Wufoo: Wufoo: Online Form Builder - Create Web Forms & Surveys Machform: MachForm - PHP HTML Form Builder - Mailer Form Creator |
| |
| | #3 | |
| Active Warrior Join Date: 2010
Posts: 80
Thanks: 3
Thanked 3 Times in 3 Posts
|
<?php $name = $_POST['username']; $email = $_POST['email']; $text = $_POST['inquiry']; //To, Subject, Message, Header mail('myemail@somewhere.com', 'Inquiry', $text, 'From: ' . $name . ' <' . $email . '>'); header('location: step3'); ?> | |
| Free E-booklet Make At Least $500 Dollars Your First Month On Adsense Get 1 year hosting for $50 Click Here | ||
| |
| | #4 |
| Warrior Member War Room Member Join Date: 2010 Location: Bryan, TX
Posts: 19
Thanks: 0
Thanked 2 Times in 2 Posts
| |
| |
| | #5 |
| Active Warrior War Room Member Join Date: 2008 Location: Seattle, WA
Posts: 35
Thanks: 3
Thanked 5 Times in 5 Posts
|
Hello, I've used this form validator on quite a few projects. All the instructions are on the following page and it's super easy to use. JavaScript Form Validation : quick and easy! If you need any assistance getting it going feel free to get in touch with me. Best of luck! |
| 300% Traffic Return check out Trippy Wire Content Exchange! (100% FREE!) Trippy Wire Content Exchage Network Trippy Wire is looking for partners in these niches niches: Humor, Movies, Gaming, Celebrities, Entertainment, Sports, Food & Drinks, Hot Women, Technology & Transportation. | |
| |
| | #6 |
| Active Warrior Join Date: 2010
Posts: 61
Thanks: 2
Thanked 6 Times in 5 Posts
|
I have used this really good looking form validation, it looks really cool. http://tetlaw.id.au/view/javascript/...eld-validation |
| HostCP - cPanel iPhone app to manage your cPanel accounts using cPanel's official API WordpressInstaller.net - Automatically install & configure Wordpress Blog, Theme, Plugins and Posts. Wordpress Installer will DO IT ALL for you in just a FEW SECONDS AND best of all, it's FREE Mihir.info - A developer's blog | |
| |
| | #7 |
| Warrior Member Join Date: 2009
Posts: 21
Thanks: 0
Thanked 2 Times in 2 Posts
|
THANKS FOR SHARING INFORMATION
|
| | |
| |
| | #8 |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
Just a quick note: do NOT depend on javascript validation. Yes, most users haven't turned off javascript in their browsers - but the bad guys do. I could use your email form to broadcast thousands of emails and you wouldn't even know it until your hosting company shut you down. Google 'php email injection'; you'll get some ideas of how to sanitize your form data before sending it. |
|
The 2nd Amendment, 1789 - The Original Homeland Security. Gun control means never having to say, "I missed you." | |
| |
| | #9 |
| Active Warrior Join Date: 2010
Posts: 88
Thanks: 1
Thanked 3 Times in 3 Posts
|
Must use JQuery validation its great.
|
| |
| | #10 |
| Night Angel Join Date: 2009 Location: Underground
Posts: 158
Thanks: 2
Thanked 14 Times in 14 Posts
|
Pay attention to CAPS LOCK - they are frowned upon. That said, whatever validation you do on client-side, it is a good practice to also validate on the server-side. Scammers will always inject data into your 'step2.php', so make sure you validate it, otherwise you will continue getting blanks and garbage emails. Just a thought! |
| | |
| |
| | #11 |
| Warrior Member War Room Member Join Date: 2010 Location: Cambodia
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
U can try regex. in javascript: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test("email address"); return true or false. |
| | |
| |
| | #12 |
| Active Warrior Join Date: 2010 Location: Phoenix, AZ
Posts: 37
Thanks: 2
Thanked 6 Times in 5 Posts
|
I modified the code you pasted for step2.php, here is a modified version that will validate your form: <?php $name = $_POST['username']; $email = $_POST['email']; $text = $_POST['inquiry']; //*****Switch to decide whether to show error or move on. $validation_switch = "ON"; //*****Change this value to a custom error message alert. $errormessage = "Error\n"; if((trim($username) == ""))) { validation_switch = "OFF"; $errormessage.= "You must enter a user name.\n"; } if((trim($email) == ""))) { validation_switch = "OFF"; $errormessage.= "You must enter a valid email.\n"; } if((trim($text) == ""))) { validation_switch = "OFF"; $errormessage.= "Please remember to enter your inquiry.\n"; } if($validation_switch == "ON"){ //To, Subject, Message, Header mail('myemail@somewhere.com', 'Inquiry', $text, 'From: ' . $name . ' <' . $email . '>'); header('location: step3'); } if($validation_switch == "OFF"){ echo "$errormessage"; } ?> I could have used an elseif there, but this makes it more clear. |
| |
| | #13 |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
Sorry, but that's not any kind of validation worth mentioning. It just checks to see if a form field is empty. That's not nearly good enough.
|
|
The 2nd Amendment, 1789 - The Original Homeland Security. Gun control means never having to say, "I missed you." | |
| |
| | #14 |
| Web Developer Join Date: 2010 Location: Wisconsin
Posts: 322
Thanks: 2
Thanked 80 Times in 74 Posts
|
SteveJohnson is correct.. None of these examples actually validates anything. You need to first strip out any code the user may have entered in any of the fields. Then see if the fields are empty, if not -- Check that the email address is valid using an array of different expression patterns. Then make sure that it was actually submitted eg. testing for the following -- Make sure that it was submitted from your actual script and not hijacked via cURL or other functions and used to spam every email on the internet. And I am just winging it, probably missed a check or 2. All of these checks need to be done with a server side language eg. PHP A really good captcha should be used also unless you want a 1000 bot submissions. JavaScript validation is for pretty checks to notify the user they messed up. Its not validation by any means. If you can't pull off all of these true validations, I suggest hiring someone that can code it properly and secure. |
| | |
| |
| | #15 |
| Warrior Member Join Date: 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
It is difficult to know what of validation that actually is, it is only to know whether a form field is empty or not.
|
| | |
| |
|
| Bookmarks |
| Tags |
| email, form, validate |
| |