|
|
Subject:
PHP Programming
Category: Computers > Programming Asked by: charlie99-ga List Price: $2.00 |
Posted:
05 Dec 2003 17:30 PST
Expires: 04 Jan 2004 17:30 PST Question ID: 284002 |
Retrieving Hyperlink parameter values in PHP I have a PHP program that creates a page with several links all to the same URL but with different parameter values in the hyperlink e.g. <a href=?FILENAME.php?VARIABLE=123?>Click Here</a>. How do I retrieve the value of VARIABLE (=123) in file FILENAME.php? chvol@aol.com |
|
Subject:
Re: PHP Programming
Answered By: googleexpert-ga on 05 Dec 2003 18:18 PST |
Hi you can retrieve the value of VARIABLE 2 ways: <? //Contents of FILENAME.php //Use $HTTP_GET_VARS For older versions of PHP $varval = $HTTP_GET_VARS['VARIABLE']; echo "VARIABLE is Equal to $varval"; ?> <? //Contents of FILENAME.php $varval = $VARIABLE; echo "VARIABLE is Equal to $varval"; ?> Please let me know if that helps you. |
|
Subject:
Re: PHP Programming
From: b0rg-ga on 06 Dec 2003 08:17 PST |
Analyze this: <?php echo "<pre>"; echo "<br>\n"; print_r($PHP_SELF); echo "<br>\n"; print_r($_SERVER["SCRIPT_NAME"]); echo "<br>\n"; print_r(substr($_SERVER["PHP_SELF"], 1)); echo "<br>\n"; echo "</pre>"; ?> |
Subject:
Re: PHP Programming
From: b0rg-ga on 06 Dec 2003 08:30 PST |
Sorry, I missunderstood your question, here's the proper suggestion, hope this would help you to unerstand what's about: If in the php.ini (php's config file) the "register globals" is turned on (which is hazardous and could be exploited by hackers) all variables you give in the url or send through <form> are automatically converted to global variables and avaliable everywhere in the script simply by using their variablename ($variable). So it is highly suggested that you turn off the "register globals" and use special arrays that are created whenever you define a variable in the url ($_GET["variablename"]) or <form> ($_POST["variablename"] section. To see how it works simply try to put somewhere in your script: print_r($_GET); try also print_r($HTTP_GET_VARS); and print_r($_POST); try also print_r($HTTP_POST_VARS); print_r -- Prints human-readable information about a variable |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |