Some features in PHP help much, especially when there is the need of working with forms. GET, POST and REQUEST are the most used and then we’ll know a little more about each of them.

GET

This collection allows the programmer can get a variable value that often comes directly from a URL. Check out the example below:

www.test.com/?x=1Ey=2

<?php

echo(“The value of X is “.$_GET[‘x’]);

echo(“The value of Y is “.$_GET[‘y’]);

?>

As WEB languages ​​do not keep this state variable is one way to move a value from one page to another.

POST

Using this collection is possible to obtain data from a particular field and use it in programming, as example below:

<FORM NAME=”form1″ METHOD=”post” ACTION=”page.php”>
Field 1:
<INPUT TYPE=”text” NAME=”field1″>
<BR>
Field 2:
<TEXTAREA NAME=”field2″></TEXTAREA>
<BR>
<INPUT TYPE=”submit” VALUE=”SEND”>
</FORM>

<?php
echo(“First value is ” . $_POST[‘field1’]);
echo(“Second value is ” . $_POST[‘field2’]);
?>

This is one of the most widely used collections in PHP since it is created from whole structure forms necessary for the operation of any type of web application.

REQUEST

This is called generic collection, it is returned the value of the last variable, according to a php.ini setting. Check out the example below:

<FORM NAME=”form1″ METHOD=”post” ACTION=”page.php?x=1″>
<INPUT TYPE=”text” NAME=”txtField1″ VALUE=”Value is”>
<INPUT TYPE=”submit” VALUE=”SEND”>
</FORM>

<?php
echo($_REQUEST[‘v’]);
?>

What is printed result is that the value “Text Field Value” according to the logical file described above.

php

These methods are part of everyday life for any PHP developer as well as the development tool of choice. Therefore, choosing the right tool you will use in your development projects. With Scriptcase you has a number of resources that will help you to have much more flexibility in their development process, meet our tool and be surprised.

By ,

July 22, 2013

a

You might also like…

5 reasons you can’t miss a Black Friday Scriptcase!

This November we bring you the biggest and most important discounts of the year! And do you know wh...

Taking a look at Scriptcase version 9.7

After the big Scriptcase 9.7 presentation event, we have a new version of Scriptcase for download, ...

October Newsletter

Follow the latest news for the month of October! Webinars, blog posts, videos, and more. WEB...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.