Latest tutorial: Making a Movieclip face another Movieclip or point on the stage | Ask Tutorial5!
 

PHP Forms

(11 votes)
Written by DanielRo   
In our contact us script tutorial you learned the basics of creating contact forms using a PHP file and a HTML form. In this tutorial we are using only one master php file, containing both the form and the php code.



In our first tutorial we used the basic approach, a HTML FORM witch sends data using POST to a PHP file. Nonetheless this is not a bad approach in creating forms and parsing data to PHP files but as you are developing a better, stronger, faster application you will need more and more forms thus creating two files for every form can get real ugly real fast.

In this technique a single PHP file is being used, containing both the HTML FORM and the PHP script.

Here is the actual script:

<?
/*Check to see if the FORM was submitted (if the "SEND" value was sent)*/
if(isset($_POST['send']))
{
/* Get the "username" and "password" values from the form */
$user = $_POST['username'];
$pass = $_POST['password'];

/* This is the place where you connect to your database
or whatever function you are using after the form is submited */
}

/* If the "send" value was not sent, then the form is displayed */
else {
?>
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
Username:
<input name="username" type="text"><br>
Password:
<input name="password" type="password"><br>
<input name="send" type="submit" value="Login">
</form>
<? } ?>



Subscribe now via RSS feed and get all the new tutorials

written by arun , October 18, 2007

hai this is very useful for me
written by barry manville , May 20, 2008

looking for tutorial to create a numbered sequence of forms--in this case want to offer a certificate that is sequentially numbered and where the customer can input a name.

end result would be a down loaded certificate that is numbered and has customers name on--
written by anbugopal , June 10, 2009

yes, need for flash action script

Do you need more help? Ask now!
 

busy
Last Updated ( Sunday, 14 October 2007 )