Go Back   Webmaster Forum > Development > Programming > PHP
REMOVE the ads below !
Reply
 
LinkBack Thread Tools
  # 1 (permalink)
Old
Junior Geek
Posts: 142
Join Date: Feb 2007
iTrader: (0)
Post PHP 03 : GET, POST, Airmail ? - 09-27-2007

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.


SENDING :


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">
</
form
Example of POST :
PHP Code:
<form method="post" action="test.php">
<
texterea name="mytext"></texterea>
<
input type="submit" value="send">
</
form

RECEIVING :
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 :
$_POST['mytext']
or
$_GET['page']

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'
}elseif($_GET['page']=='2')
{
?>
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 !


Thanks,
Aqua


-------------------
http://www.aquafolie.org

Last edited by aquafolie : 09-27-2007 at 04:41 PM.
Reply With Quote
Reply


Thread Tools



Advertise Here for just $6 per month

vBulletin®, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. | SEO by vBSEO | Skin developed by vBStyles.com