Form Handling

Form Handling1. We are going to be working with the $_Post or $_Get arrays. They basically tell the form if i needs to post something, or get something. In this case we are going to be showing you the basics of a contact email form, so we will be using the $_Post array. Lets create a new file and name it form.php. Below is an example of a simple form asking for name and email address, so lets copy and paste that into the blank file.

<form id="userDetails" name="userDetails" method="post" action="sent.php"> Your Name:
<input type="text" size="45" value="" name="name">
E-mail Address:
<input type="text" size="200" value="" name="email">
<input type="submit" value="Send" name="validate">

2. Now we are going to be displaying this information on the sent page. If you notice, on the above form the action will (on send) redirect you to the defined page. We called that page Sent.php so lets create a new file called sent.php and paste the following code.

<?php
print  "Welcome "  .  $_POST [ "name" ] .  "<br>" ;
print  "I see you are "  .  $_POST [ "age" ] .  " years old! <br>" ;
?>

3. For an extra feature you have the option of having users confirm their submission by changing the action in step one and have it redirect to say confim.php. You can create a blank file and name it (confim.php) and then simply add this form and a link to sent.php so they know that their message was successfully sent.

<?php
print  "Are you sure you would like to submit this information ? <br>" ;
reset  ( $_POST );
while(list( $key ,  $val ) =  each  ( $_POST ))
print  $key  .  " = "  .  $val  .  "<br>" ;
?>

Related Articles

  • Submit Form Conditionally - JavaScript
    In the long-gone days of the early Internet, having a form on the website was tantamount to dabbling with cutting-edge technologies. Intricate Perl scripts and esoteric CGI scripts were required to process those forms and people used to suffer bouts of cold sweat whenever there manifested a need.....
  • Abandoned Shopping Carts
    Are your customers abandoning their shopping carts prior to closing a sale? If so, you need a professional website design company to review your site and to provide website development services to ensure that your shopping cart system is effective in closing sales with your customers. Online shop...
  • Using SOAP in PHP
    Implementing webservice servers and clients using SOAP and PHP. This paper has examples and explanations regarding implimenting effective webservices.
  • 10 Tips For Buying Domains on Ebay
    There are bargains to be had buying domain names on EBay. I buy a few every week and bid on lots more. Heres a few tips for a successful domain buying experience on EBay.
  • Web Service Messaging
    Web services are revolutionizing the Internet by enabling applications to speak a common language: XML. While Web services technology enables the execution of remote functions, it does not provide a robust infrastructure for handling information.
  • Form Mail via CDONTS
    ASP gives you the power to send mail using the CDONTS mail object. This script will send an email from a user to whichever email address you choose...
  • Form Validation
    Learn the different ways of validating your form with Javascript.
  • Uploading Files With PHP
    Upload an image or file to your server without using your FTP.
  • Create User Friendly Confirmation Pages
    Including a form on your website is the best way to get feedback from your visitors. You can have a form to gather your visitors email address so that they can subscribe to your ezine. Or you can have a form to collect visitors comments about your site. Also, forms allow your visitors to send.....
  • E-mail form using HTML and PHP
    Sometimes its a nice touch to include an e-mail feedback form on your contact page or elsewhere on your web site. Lets create an e-mail form using html and a simple php script to send it along.

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.