You probably already know that you can get variable from a html form in php using $_GET and $_POST, you use $_GET if the html form is like: <form name="name" action="form.php" method="get"> and use $_POST if it is <form name="name" action="form.php" method="post">.

But what if you want your php to work for both post and get datas in the same time, to precess the form whatever it was in post method or get method, you will then think to use if conditions to check whether of two methods was used:

if (isset($_POST['var']))
// process data...
if (isset($_GET['var']))
// process data in the same way...

BUT there is a little and usefull solution: $_REQUEST, because $REQUEST can get any form field value, whatever it was GET or POST method, it does not care.

This means that $_REQUEST['var'] = $_POST['var'] if the form was in post method, and $_REQUEST['var'] = $_GET['var'] if the form was get. ('var' is the field name you want to get its value)
So now you will not care what method the form use :)

You can also use isset() with $_REQUEST, for example:
if (isset($_REQUEST['var'])) is the same than if ( isset($_POST['var']) or isset($_GET['var']) )

I hope this little tip will help you, we will provide best php tips, scripts as well as php tutorials.


Pratyush Nalam said...

Thanks for the tip!

rize wordpress said...

Rize PHP practice consists of Dedicated PHP Developers certified in related field from reputed universities and colleges.


Thanks so much

PHP Tutorial For Beginners with Examples PDF said...

excellent piece

Fully Help said...

Nice blog...Very useful information is providing by ur blog. Great beginning php tutorials Very clear and helpful for beginners.

Anonymous said...

Yeah.. nice info.. Thnx bro.. :)

jhansi joe said...

This fundamentals of PHP programming helped me to improvise my skill set in PHP development.
PHP Training in Chennai|PHP Course in Chennai

mary Brown said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP Training in Chennai | Online PHP Training

PHP Training in Chennai | Online PHP Training

Jessica George said...

Superb explanation & it's too clear to understand the concept as well, keep sharing admin with some updated information with right examples.Keep update more posts.

Digital Marketing Company in Chennai

ranasing rajkumar said...

Thanks for your informative blog!!! Your article helped me to understand the future of Core Java programming language. Keep on updating your with such awesome information.
White Label Website Builder

kim john said...

Thanks for sharing the information about PHP Training Chennai .
PHP Training in Chennai
PHP Course in Chennai

Amirtha rao said...

I went through your blog and it’s totally awesome. Keep on updating your site with such informative post. If possible please include rss feed for your blog.
web designing course in chennai|Best web designing institute in chennai