php, mysq lpart4(processing html form)

Post on 22-May-2015

1.226 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

how to gwhow to validate php form

TRANSCRIPT

Processing HTML FORM

Author:- Subhasis

CMC

The form code looks as like below

Output of the code will be

html form tagsForm Tags Output

<input type = "text" name = "name"/>

<input type="radio" name ="gender" value ="m“/>

<input type="CHECKBOX" name="age" value ="Y" checked/>

<SELECT name = "education"><option selected value=“pg">P.Graduate</option>

</SELECT>

<input type="submit" name="submit" value="submit">

<TEXTAREA name = "aboutu" rows ="5" cols ="28" ></TEXTAREA>

Main form tag

• Method =“post” – This is the way of processing our userfilled data into the form. Instead of „POST‟ we can use„GET‟.

• GET – when we use get method the data processed willbe visible. The amount of data is to be sent is limited

• POST – when we use POST method the data processedwill be not visible. The amount of data is to be sent is notlimited.

Continue

• When we process the form the html sends the data to file which is inaction tag. Here when the form will process it will sends to“formfill.php”.

• We need some php code to get those values which will be sent by theform tag .

• We have three types.▫ $_GET = we used to get the values from html form when method is get▫ $_POST = we used to get the values from html form when method is

post▫ $_REUQEST = it works on both .

PHP code to get the form values

• In PHP the $_GET,$_POST & $_REQUEST arespecial array in PHP.

• It collect the information which filed has collectedthe values .

• Simply there is no value about the fields on whichthere is no values entered by the user.

• To check that use the step by step tutorial. I will use$_POST for this what ever you want you can referelse you can refer what I am referring.

Checking the Special array $_POST

• Step -1 :- write the html file with form as below.

Next step is to write aphp code for processing,the name will be inaction tag as below. Heremy php file name is“test.php”.Let‟s write that

Continue ….

• Step – 2 :- writing the php file “test.php”

What is $_POST,$_GET & $_REQUEST ?

• There are three special global arrays in PHP.

▫ $_POST

▫ $_GET

▫ $_REQUEST

• When ever you submit any data to get thosevalue you can use any one of the above array.

• $_POST is more robust than $_GET,$_REQUEST is combined both of them.

Cont’d……

• $_GET is not secured .

• $_GET is not capable to send large amount of

data

• $_POST is secured and able to send unlimitedamount of data.

• So $_POST is more preferable.

Let’s receive data sent by HTML form

• To fetch the data from form we have to specifyname for each element of the form.

• Once you do that any data you will send from

FORM it will be fetch by the special array$_GET & $_POST.

• To reuse it you can store it to some variable and

do what ever else you want to do.

An example(form code)

PHP code to process

Form validation

top related