PDA

View Full Version : Using hidden input type to send php data in the request problem.



FlashNewby
March 11th, 2005, 06:34 PM
I have this code in a file called saveClientUtility.php:



<a href="retrieveClientUtility.php">Retrieve</a>

followed by


<input name="userRet" type="hidden" value="<?php echo ($user); ?>" />


My problem is when I click on the Retrieve link, the userRet value is not
getting passed in the request to retrieveClientUtility.php. I have viewed the source of saveClientUtility.php and the value for
userRet is showing up so I know that value is okay.

It's when I get to the retrieveClientUtility.php and do a $_POST['userRet'] that I don't see any value. I've also tried using $_REQUEST['userRet'], $_GET['userRet'] and these have no data as well.

Any help would be appreciated.

Thanks

λ
March 11th, 2005, 06:49 PM
Why don't you just do this:



<a href="retrieveClientUtility.php?userRet=<?php echo (urlencode ($user)); ?>">Retrieve</a>


That should work :)

FlashNewby
March 12th, 2005, 07:12 AM
I did try this and got it to work but was trying to keep the id out of the querystring. I'll use this and keep looking for another way.

Thanks

fluid_tw0
March 12th, 2005, 09:53 AM
use this:

<a href="retrieveClientUtility.php?u=<?php echo (str_rot13 ($user)); ?>">Retrieve</a>

in retrieveClientUtility.php use

<?php

$userid = str_rot13 ($_GET['u']);

?>

fluid_tw0
March 12th, 2005, 09:54 AM
or use sessions - it's even easier!

FlashNewby
March 12th, 2005, 09:58 AM
Does str_rot13 do some encrypting or something?

Ya know fluid_tw0 I thought about using sessions, and your right I will probably use sessions. It's cleaner as well.

Thanks

fluid_tw0
March 12th, 2005, 10:08 AM
str_rot13 - encodes/decodes string

sessions are the best solution here

teiz77
March 14th, 2005, 03:07 AM
or you can make a form out of it... so you can acces the variable as post data.

But sessions are good... you can also use it to acces the variable on other pages.

FlashNewby
March 14th, 2005, 07:09 AM
Great, thanks guys!