Posted By

jonkemp on 07/01/10



Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


PHP Check for HTTP POST variables

 / Published in: PHP

Check to see if HTTP POST variable exists before doing something with it.

  1. if ( !empty($_POST['name']) ) {
  2. $name = $_POST['name'];
  3. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: GMali on March 9, 2011

very simple, but a very common piece of code. Handy for copy pasting.

Can also be written as:

if ( isset($POST['name']) ) { $name = $POST['name']; }

for all those who always like to be positive ;)

You need to login to post a comment.