2:52 AM

PHP : Get , POST ..

posted under by FR3@K | Edit This

Everything we saw spoke about some variable. I said for example : "$i=1;".

Okay, but it isn't really interactive with the reader.

In order to be interactive we need to permit the reader to send some
information, for example by a form.

The form can send a lot of thing but for instance we just see GET and POST.


If you use the method 'get' you will send information into the URL like :

test.php?name=value&name2=value2 and can can send this sort of URL directly by
the HTML "<a href=".

but you are limited to 255 characters and some of them are restricted.

If you use the method 'post' you will send information without the URL and you
can send a lot of text, code.... but you need to use a form to sending it.

Example of GET :

PHP Code:

<a href="test.php?page=1">Page 1</a>

I don't use any php code to send an information.

the same by form :

PHP Code:

<form method="get" action="test.php">

<input type="text" name="page" value="1">

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


Example of POST :

PHP Code:

<form method="post" action="test.php">

<texterea name="mytext"></texterea>

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



Now An information has been sent to test.php

In order to interact you need to declare or to take the variable POST or GET
like this :




They are the same variable as $whatyouwant and you can manipulate them like we
saw before.

Example :

PHP Code:

<?php if ($_GET['page']=='1')


echo 'all the text html you want'



The other text you want for the page 2

<?php } // note : I close the quote php and reopen one after


So now we can see how to interact with your reader !


Make A Comment