Adblock breaks this site

PHP - [Tutorial] #2 - Webforms and PHP

Discussion in 'Web Programming' started by speedster239, Sep 8, 2007.

  1. speedster239

    speedster239 Forum Addict
    Java Programmers

    Joined:
    Jan 21, 2007
    Posts:
    313
    Referrals:
    0
    Sythe Gold:
    0
    PHP - [Tutorial] #2 - Webforms and PHP

    Difficulty: Extremely Easy

    Almost everyday you'll fill out a webform written in html. You might not know it but when you press the "accept" button their is usually a php script being executed!

    Today were going to learn how to program a simple webform where you'll enter your name and the variable will be passed to a php script in which it will be output using the "echo" function!

    Step 1:

    We going to create a simple webform as below...

    Code:
    <form action="output.php" method="post">
    Name: <input type="text" name="name"><br>
    <input type="Submit">
    </form>
    As you can see above this will create a simple form with and input bogs and a submit button. At the top where it says ( <form action="output.php" method="post"> ) this is defining that when the submit button of the form is pressed the output.php script will be executed!

    Step 2:

    Now that we've created the webform we will now create the output.php file!

    Code:
    <?
    $name=$_POST['name'];
    echo "$name";
    ?>

    The above script is very simple. It gets the post "variables" from the form we created. The variable, as defined in the form is 'name'. It gets the text value the user enters and turns it into the $name variable. Note, all variables in php are started with a "$" sign!

    The third line has the php script output the value of the name variable!

    Step 3:

    Upload these files to your webserver, run the form and it should work!

    Congratulations...
     
  2. 1-DUB

    1-DUB Forum Addict

    Joined:
    Jan 21, 2007
    Posts:
    282
    Referrals:
    0
    Sythe Gold:
    0
    PHP - [Tutorial] #2 - Webforms and PHP

    once again nice tut and i will be looking for another one, could a mod mabey ask for a php, or weblang forum?
     
  3. Dingo212

    Dingo212 Guru

    Joined:
    Aug 28, 2005
    Posts:
    1,284
    Referrals:
    3
    Sythe Gold:
    14
  4. speedster239

    speedster239 Forum Addict
    Java Programmers

    Joined:
    Jan 21, 2007
    Posts:
    313
    Referrals:
    0
    Sythe Gold:
    0
    PHP - [Tutorial] #2 - Webforms and PHP

    Thanks :D, and yes..their are many more coming in both the PHP and Java sections..
     
  5. 1-DUB

    1-DUB Forum Addict

    Joined:
    Jan 21, 2007
    Posts:
    282
    Referrals:
    0
    Sythe Gold:
    0
    PHP - [Tutorial] #2 - Webforms and PHP

    i am very pleased to here that, good luck with you tuts and hopefully you will get a user ed rank one day
     
  6. Quikuli

    Quikuli Member
    Banned

    Joined:
    Aug 19, 2007
    Posts:
    79
    Referrals:
    0
    Sythe Gold:
    0
    PHP - [Tutorial] #2 - Webforms and PHP

    This is good tutorial too...
     
< Perl Tutorial | FileFinder, find the files you are looking for. >


 
 
Adblock breaks this site