Working with HTML Forms

text zoom

Working with HTML Forms
 

1. The HTML Form


<html>
<head>
<title>A BASIC HTML FORM</title>
</head>
<body>


<FORM NAME ="form1" METHOD =" " ACTION = "">


<INPUT TYPE = "TEXT" VALUE ="username">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">


</FORM>
</body>
</html>


 



6. Getting values from a Text Box


 


<INPUT TYPE = "Text" VALUE ="username" NAME = "username">


 


When you submit the form butoon you can get the value of textbox on the same page or the page whose name you given in action tag of form.


The value of text field will gte by the name of the textfield that is "username"


<?


echo $_POST["username"]; // If form submit by POST method


echo $_GET["username"]; // If form submit by GET method


echo $_REQUEST["username"]; // Works for both POST and GET method of form


?>



7. Checking if the Submit button was clicked


We are assuming that form is submitted by POST method


<?


if (isset($_POST['Submit'])) { }


 


// isset() Its a php function that check wheather a variable is set or empty.


?>

                    

Copyright © 2008 VisualBuilder. All rights reserved