AW: [PHP] newbie question ; calling php script with parrameters from html

From: Date: Wed, 02 Feb 2005 23:13:53 +0000
Subject: AW: [PHP] newbie question ; calling php script with parrameters from html
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207946@lists.php.net to get a copy of this message
Hi, There are multiple Ways of getting that string. If your PHP-Server has globals=on in php ini you will recive that string in $selection variable. If not you recive it in $_GET["selection"] So I use a function to handle POST and GET Variabels. function getpost_ifset($test_vars) { $return = FALSE; if (!is_array($test_vars)) {$test_vars = array($test_vars);} foreach($test_vars as $test_var) { if (isset($_POST[$test_var])) { global $$test_var; $$test_var = $_POST[$test_var]; $return = TRUE; } elseif (isset($_GET[$test_var])) { global $$test_var; $$test_var = $_GET[$test_var]; $return = TRUE; } } return $return; } If i now want to get a ariable i either POST or GET from an URL i don't care if POST or GET. I just do getpost_ifset("selection"); and then I have a variable called $selection in my code with the given value. You could also do something like this. if(getpos_ifset("selection")) { echo "Selection variable is there with value: ".$selection; } else { echo "No Selection Variable givin in Link"; } Hope that helps. Mirco Blitz -----Ursprüngliche Nachricht----- Von: Sagaert Johan [mailto:sagaert.j@belgacom.net] Gesendet: Mittwoch, 2. Februar 2005 11:38 An: php-general@lists.php.net Betreff: [PHP] newbie question ; calling php script with parrameters from html can i use this kind of construction in my html code ? <a href="test.php?selection=high">Select high</a> if yes , how do i retrieve the passed string in the php code Johan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#207946) next »