Scenario
Let's pretend you'd like to collect user
information for Newsletter Subscription, and
needs to create a Web Form for this purpose.
You'll simply need two main files, to
accomplish this. Read forward and enjoy this.
Files Needed.
- An HTML file that will contain your Web Form script. [Web Form Script].
- A PHP file that will be used, processing the Web Form. [Web Form Processor Script].
Creating The Required Web Form.
In the first place, you'll create an HTML document, copy the Web Form Script below, paste it into the <body> tag of your HTML document, edit it as required, and save it as [userdata.php].
Web Form Script. [userdata.php]
<div> <form name="userdata" method="post" action="verify.php" onsubmit="return checkfields()"> <table align="center"> <tr> <td colspan="2"> <p><strong>Contact Form:</strong></p> </td> </tr> <tr> <td> <p>Select Title:</p> </td> <td> <select name="Title"> <option>Mr.</option> <option>Mrs.</option> <option>Miss.</option> <option>Ms.</option> <option>Dr.</option> <option>Prof.</option> <option>Prof.Dr.</option> </select> <input type="hidden" value="youremail@yoursite.com" name="sendto"> </td> </tr> <tr> <td><p><span style="color:#F00">*</span> Full Name:</p></td> <td><input size=35 name="Name"></td> </tr> <tr> <td><p><span style="color:#F00">*</span> Email Address:</p></td> <td><input size=35 name="Email"></td> </tr> <tr> <td><p>Send Me News:</p></td> <td><p><input type="radio" name="list" value="Mothly"> Monthly.<br><input type="radio" name="list" value="Weekly" checked /> Weekly.<br></p> </td> </tr> <tr> <td colspan="2" align="center"> <input type="reset" value="Reset" /> <input onclick="validate();" type="button" value="Submit" /> </td> </tr> <tr> <td colspan="2" align="center"> <p style="font-size:10px"> <span style="color:#F00">*</span> indicates field is required. </p> </td> </tr> </table> </form> </div>
Note The Following, Inside The Script Above Carefully.
- <form name="userdata">
- You should give your Web Form a unique name you can later refer to from a script like JavaScript. See Script Below.
- <form method="post">
- Your Web Form should use the attribute method= "post" because in this case, it's the user posting information.
- <form action="verify.php">
- The attribute action should contain a value "verify.php", which is the Web Form Processor file you'll create. And this must also reside inside the same folder containing the rest of your file.
Creating The Required Web Form Processor. [PHP]
This Tutorial Requires The Basic Knowledge Of PHP And HTML.
Now, you'll create another file. Copy the Web Form Processor Script below into it, edit it appropriately and save it as verify.php.
Remember:
The <form> element above, contains an "action" attribute with a value "verify.php".
This tells you that, user data when submitted, will be sent to a destination file named "verify.php", which is the Web Form Processor file you are about to, or may have just created.
Web Form Processor.[verify.php]
<?php //Add your reCAPTCHA Private Key script here. $to = $_POST['sendto'] ; $Title = $_POST['Title']; $from = $_POST['Email'] ; $name = $_POST['Name'] ; $headers = "From: $from"; $subject = "User Subscribtion Data"; $fields = array(); $fields{"Name"} = "Name"; $fields{"Email"} = "Email"; $fields{"list"} = "Mailing List"; $body = "I have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: noreply@yoursite.com"; $subject2 = "Thankx for your mail"; $autoreply = "Thankx for your mail. I'll get back to you very soon."; $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: https://www.yoursite.com/contact/thankyou.html" );} else {print "Error occured sending your mail, notify info@yoursite.com"; } ?>
You'll Need To Edit The Following Lines In The Above Script.
- Adding reCAPTCHA is optional. However, attaching it to your Web Form extends its security.
- Using reCAPTCHA you'll also be helping in digitizing old books written before the existence of Computer.
- You may edit the information on the line that reads;
$subject = "My Site1 User Data"
- This is the title notifying you from where the data is coming.
- You must edit the line that reads: https://www.
yoursite.com/contact/thankyou.html
- This is the file that will load after a successful data sending by a user. It must be placed inside the same folder your Web Form and Processing files are residing.
- And the line that says; "Error occurred sending your mail, notify info@yoursite.com" must also be edited appropriately.
FastLaneTip #1.
Please note that your files must be uploaded onto a web server before they'll work.
Validate Form Behavior | JavaScript.
This Tutorial Requires The Basic Knowledge Of Javascript And HTML.
Javascript Function.
Copy and paste the javascript below into the <head> section of the HTML document holding your Web Form. This will take care that users enter data into the required fields. However, script must be edited according to your form scripting data.
Add the following attribute and value into the <body> tag like this; <body onload="reset()">
Below Is The Required Javascript.
<script language="javascript"> <!-- function reset() { document.userdata.Title.value=""; document.userdata.Name.value=""; document.userdata.Email.value=""; } function validate() { if (document.userdata.Name.value.length==0) { alert("Please Enter Your Full Name "); return false; } if (document.userdata.Email.value.length==0) { alert("Please Enter Your Email Address"); return false; } document.userdata.submit() return true; } //--> </script>
Extend The Security For Your Web Form.
After creating your Web Form, securing the required fields, and processing it using the provided scripts.
The next important thing you'll want to add into the extension of securing your Web Form is, attaching it with a CAPTCHA. Now learn how to implement this from the adding CAPTCHA to PHP tutorial.
How To Create And Process Web Form.
Hope you're able to add it, if not try again. Good Luck.
Top Articles.
- The Hottest Stuff. Burning Hot!
- How To Find Success In Business
- Free Website Creation Tutorials
- Free Blog Creation Tutorials
- Scripting Tutorials
- Adobe Trail Products And Tutorials
- Sony Creative Software Tutorials And Trails
- Entertainment Corner, More Music And Videos
- Explaining Bitmap And Vector Graphics
- Desktop Audio Recording Setup
- Audacity, A Robust Free Audio Recording Software
- Learn Digital Sound Recording And Editing.
- Learn How To Use FL-Studio Easily.
- Selective Youtube Web-Video Tutorials.
- Get The In-Depth Free SEO Training.
- Affiliate Marketing Tips And Tricks
- Ghana Oil Boom.
- File Synchronization Tool
- Get Free Templates For Your Website
- Download Absolute Free Software
- Visit Our Knowledge Base
Clicks4UrMind
Man will give you worldly powers, and make you feel on top of all, note this is temporally and could be redrawn at anytime sending you back to the ground floor of life. However, the Lord Almighty, the one and the only rightful ruler of the Universe, blesses everlastingly.
Knowledge is Power, but Power is not Knowledge. Wisdom is the truthful Power that identifies the Knowledge within the man. And only, I repeat 3x. Only the almighty God has the power to bless the man with his Wisdom forever.
To achieve the Lord's blessings, cease not praying daily, asking for his Wisdom, and you'll be blessed abundantly...
Advertise your business here
SPYERA PHONE
Spyera Phone version is software that you install on a smart phone to monitor everything happening on the phone. After installation, SPYERA secretly records events (sms, call history, phone book, location, emails, What's App messages, IM, Facebook Chat, Skype, See photos taken and many more...) that happen on the phone and delivers these information to a web account, where you can view these reports 24/7 from any Internet enabled computer or mobile phone. SPYERA also allows you to listen to the surroundings of the target mobile , listen to the phone conversation and to know the location of the device.
Please, Kindly Donate What You Can, Enabling Us Pay Hosting And Domain Costing, And Do More.