Re: SV: SV: [PHP] Passing a variable invisibly via a href?
| From: | Erik Price | Date: | Tue, 02 Apr 2002 16:10:06 +0000 |
| Subject: | Re: SV: SV: [PHP] Passing a variable invisibly via a href? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-91165@lists.php.net to get a copy of this message | ||
On Tuesday, April 2, 2002, at 10:28 AM, Daniel Alsén wrote:
I use the variable $change to set the text size in my stylesheet: if (isset($text_size)) {echo $text_size;} else {echo "10"; $text_size = 10;} And i set the variable via a link: <a href="<? echo $PHP_SELF; ?>?change=inc"> (or change=dec) Now - i don´t want the variable to be visible. And i would prefer if the variable didn´t get set every time someone hit reload. Or am i attacking this changing-text-size-thingy the wrong way?Hmm. I thought that I had a clever solution for you, but I don't. The one that I came up with would probably be far more complex and inelegant than you would ever want to use. If you were submitting your data to a database or some kind of service, then it would work (I am thinking of the PostToHost() function in the archives), but since you are trying to set a session variable, you really need to refresh the page in the process. This means that either using a form with POST data or the querystring method that you mention above is really the best way to do it. If you used a form with POST data, you'd probably want to use radio buttons or make a little listbox and a submit button, like: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select name="change"> <option value="inc">Increase Size</option> <option value="dec">Decrease Size</option> </select> </form> This would keep your querystring/URL free of extra data like "page.php?change=inc". Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com