Page 1 of 1

Hiding GET variables in address bar solution

Posted: Tue Jan 21, 2003 1:21 pm
by ppera
It is mostly from estetical reasons, not from some protection.

As I know only way to hide GET variables is usage of frames. But in that case I don't like that pressing refresh always put back to start page.
So I made some little PHP script to override it.

index.php has this:

if (!session_is_registered('frpag')) session_register("frpag");
if (!isset($frpag)) $frpag = "index2.php" ;


<frameset cols="*" rows="*">
<frame src="<? echo $frpag ?>" name="nav" frameborder="0" /> ......

And at begin of all pages stays:

session_register("frpag"); $frpag = $PHP_SELF ;

So pressing refresh resets that page to initial state. It is probably even better than without frame, when refresh keeps variables.
It's prehaps nothing new, but I didn't see it during my lot of search about it last couple days.

Posted: Tue Jan 21, 2003 2:41 pm
by Joan Garnet
Have a lok at this link
You'll find it very useful

Posted: Tue Jan 21, 2003 3:00 pm
by ppera
Well, I saw it during my intensive search.

CURL extensions I can not use by my host (of course).

HTTP Post will not work for database listings and similar...

If (($of)>$l-1){
echo "<a href=".$PHP_SELF."?q=".$q."&of=".($of-$l)."&l=".$l."&cs=".$cs."&r=".$r."><font size='".$navs."' color='".$textc."'><b><</a> " ;

This is code fragment for listing. I don't see other way how to realize jump on specific page by listing database.

You may see how it works:
first page by menus...

Posted: Wed Jan 22, 2003 9:05 am
Interesting how it is? HTTP Post will not work for database listings and similar... Maby you some there mistaking?
From manual:

Code: Select all

if ($HTTP_POST_VARS['action'] == 'submitted') {
   print '<pre>';

   print '<a href="'. $HTTP_SERVER_VARS['PHP_SELF'] .'">Please try again</a>';

   print '</pre>';
} else {
<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
   Name:  <input type="text" name="personal[name]"><br>
   Email: <input type="text" name="personal[email]"><br>
   Beer: <br>
   <select multiple name="beer[]">
       <option value="warthog">Warthog</option>
       <option value="guinness">Guinness</option>
       <option value="stuttgarter">Stuttgarter Schwabenbräu</option>
   <input type="hidden" name="action" value="submitted">
   <input type="submit" name="submit" value="submit me!">

Posted: Wed Jan 22, 2003 10:09 am
by ppera
Sorry Wizard, but I talk here about GET variables, FORM is no good for me (although it could be good because of hidden variables) but I need hyperlinks with lot of variables, and want to hide them from address bar.

This is'n good example:
print '<a href="'. $HTTP_SERVER_VARS['PHP_SELF'] .'">Please try again</a>'; - you have here only URL

I need something like this:
print '<a href="'.$HTTP_SERVER_VARS['PHP_SELF']."?l=". $HTTP_SERVER_VARS['lim'] .'">Lim50</a>';

But it outprints (of course) l=50 after URL....

To explain better: I get filelist from database for download them, so I need hyperlinks for easier jump to diverse pages of list. And by it keep some settings of page. PHP can't pass apropriate variable because it doesn't know what link will user press.

Other solution with some Java

Posted: Thu Jan 23, 2003 1:03 pm
by ppera

With some little Java we can force that text link act as form, so we can use hidden variables. It's by Christopher S L Heng's text 'How to Make a Text Link Submit A Form ' .

Here is example with two variables:

This goes somewhere between head tags:

<script language="JavaScript" type="text/javascript">
function getst ( se1, se2 )
document.stform.l.value = ( se1 ) ;
document.stform.cs.value = ( se2 ) ;

document.stform.submit() ;

This is code for hyperlink with 2 hidden variables:

<form name="stform" method=post action="<? PHP_SELF ?>">
<input type=hidden name="l" > <input type=hidden name="cs" >
<a href="javascript:getst('20', '<? echo $cs ?>')">20 </a>

$cs=..... #code for changing variable

<a href="javascript:getst('30', '<? echo $cs ?>')">30 </a> </form>

Here is first 'variable' actually constant, but it's not relevant.

Variables will be sent as hidden, this is more secure than frame method. Just need to hide displaying from status bar too...

Posted: Fri Jan 24, 2003 1:48 am
by Joan Garnet
Yeah, that's it :)
It's a bit complicated though... Well, it's kind of handy anyway.
ThanX for sharing !