Monday, 5 September 2011

PHP Tutorial: Method ( HTML +PHP )

For this post,i will explain about the function of method:

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


Method : tell to the browser how the form information should be sent. most popular methods . GET and POST. So,change it like this:.

<FORM NAME ="formOne" METHOD ="GET" ACTION = "">

then copy this script n run it on the browser:

<html>
<head>
<title>The First HTML form</title>
</head>
<body>

<FORM NAME ="formOne" METHOD ="GET " ACTION = "">
<INPUT TYPE = "TEXT"  VALUE ="username">
<INPUT TYPE = "Submit"  Name = "SubmitOne"   VALUE = "Login">
</FORM>

</body>
</html>

Remember to save it as PHP file! eg: GET.php

run it and then,click the 'Login' button,and u will notice that the address will change from this:

http://127.0.0.1/bsicForm.php

to be like this:

http://127.0.0.1/bsicForm.php?SubmitOne=Login

u r notice ryte?if not it is never mind,but we will concentrate on this :
                                     
                                                     ?SubmitOne=Login

so,to explain this....it is because of using the GET method.So SubmitOne was the NAME of the button, and Login was the VALUE of the button (the text on the button). u can use the GET method when the returned data  is not important information that needs protecting.That why the returned data is display on address bar.

N/NOTE: more information,next post,we will discuss another method:POST 



No comments:

Post a Comment