PDA

View Full Version : sending hidden url variables


belinha
10-02-2002, 12:35 PM
Hello all,
I hope someone can help me with this question, even to say it is not possible!

I'm coding PHP and at a certain point I have to redirect to a different page (without using "include"), but at the same time I have to keep/send two variables. I'm using javascript to send the variables via url:
<?
echo "<SCRIPT language=JavaScript>";
echo "window.location.replace('mypage.php?codbadge=$codbadge&passwd=$passwd');";
echo "</SCRIPT>";
?>

If I do it like this (it works) however, the two variables will be read at the URL bar of the browser (ex:http://www.whatever.com/mypage.php?codbadge=1111&passwd=2222 ). I'd prefer to keep these hidden, but I must send them to the next page.

Can someone help me with this or is it impossible?
Thanks for any help
Belinha

brothercake
10-02-2002, 12:46 PM
You can use POST data - write the variables into a form, and then use javascript to auto-submit the form. You will generate a history event this way - unlike the replace method you're currently using - but other than that it will amount to the same as what you;re currently doing.

whammy
10-02-2002, 12:58 PM
<form action="mypage.php" method="post" name="blah">
<input type="hidden" name="codbadge" value="<?php echo($codbadge); ?>" />
<input type="hidden" name="passwd" value="<?php echo($passwd); ?>" />
</form>

<script language="javascript" type="text/javascript">
<!--
document.blah.submit();
// -->
</script>


If I remember PHP syntax correctly that should work for you...

belinha
10-02-2002, 01:05 PM
Worked great!!!
Thanks a lot to both!
Belinha

............................
Final code:
<?
echo "<form action=accesso.php name=vai method=POST>
<input type=Hidden name=codbadge value=$codbadge>
<input type=Hidden name=passwd value=$passwd>
</form>";
echo "<SCRIPT language=JavaScript>";
echo "document.vai.submit()";
echo "</SCRIPT>";
?>
............................

belinha
10-02-2002, 01:29 PM
Worked great!!!
Thanks a lot to both!
Belinha

............................
Final code:
<?
echo "<form action=accesso.php name=vai method=POST>
<input type=Hidden name=codbadge value=$codbadge>
<input type=Hidden name=passwd value=$passwd>
</form>";
echo "<SCRIPT language=JavaScript>";
echo "document.vai.submit()";
echo "</SCRIPT>";
?>
............................