Quantcast
Channel: Webmaster Tools » post
Viewing all articles
Browse latest Browse all 2

Get All Variables in PHP from GET or POST

$
0
0

Use this PHP code to pull variables that were just posted, such as from an HTML form:

extract($_POST);
extract($_GET);

It's then a good idea to 'clean' the variables of any html spam or injection attacks. If you're getting ready to insert into MySQL, first make a connection with your database, then do this to your variable(s) (substituting your variable name for 'variable')::

$variable = mysql_real_escape_string($variable);

To get specific variables from GET or POST, you do this (substituting your variable name for 'variable'):

$variable = $_POST['variable'];

$variable = $_GET['variable'];

To show all your active, set, variables, use this:

var_dump(get_defined_vars());


Viewing all articles
Browse latest Browse all 2

Trending Articles