Go Back   Web Server Hosting Forum by BODHost > Support > Tutorials and Documentation
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-22-07, 19:45
BOD Member
 
Join Date: Nov 2007
Posts: 5
Default Proof of concept

If anyone is having trouble using forms with PHP, here is a tutorial.

First you need to create your form, I will place it into a table to make it neat
PHP Code:
<form action="action.php" method="POST">
     <
table>
          <
tr>
               <
td>First Name</td>
               <
td><input type="text" name="fname" /></td>
          </
tr>
          <
tr>
               <
td>Last Name</td>
               <
td><input type="text" name="lname" /></td>
          </
tr>
          <
tr>
               <
td></td>
               <
td><input type="submit" value="Go" /></td>
          </
tr>
     </
table>
</
form
Next you need to create the action.php, which I will explain.

PHP Code:
<?php
     $firstname 
$_POST['fname'];
     
$lastname $_POST['lname'];

     echo 
"Hello my first name is <b>$firstname</b> and my last name is <b>$lastname</b>";
?>
The first two lines get what the user entered in the form and save it into the corresponding variable, $firstname, or $lastname. Then it echoes it out to the browser for the last line.
__________________
-Brandon Roach
Reply With Quote
  #2 (permalink)  
Old 11-22-07, 20:56
Rocky's Avatar
Administrator
 
Join Date: Nov 2007
Posts: 123
Default

Hey Brandon,

Man... you've been too good a very nice & concise tutorial for PHP beginners...
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 01:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.