Jump to content

Setting request object


invincible_virus

Recommended Posts

We can redirect a request to another url using something like -
header("Location:./xyz.php");
Now, I want to redirect to xyz.php with some variables to be set in request object. I know one way of doing a redirect to xyz.php?name=value.
But, I don't want all my variables to be visible in address bar.
Any idea abt how to do it??
Link to comment
https://forums.phpfreaks.com/topic/32287-setting-request-object/
Share on other sites

Actually, I want to set these variable in some request object, so that I don't need to unset them on the destination page.
Like in J2EE, there variables can be set in session object or request object, is there any equivalent of J2EE's request object in PHP ??
if you're running on apache, you could use .htaccess and mod rewrite. Instead of xyz.php?name=value, you would send them to value.html.

a quick google search for "htaccess mod rewrite" will give you tons of hits. Here's a good one http://corz.org/serv/tricks/htaccess2.php
One thing you can do:
[code]
<html>
<body onload="document.formname.submit();">
<?php
    echo '<form name="formname" action="yourURL">';
    foreach ($_POST as $formname) {
echo '<input type="hidden" name="' . $formname . '" value="' . addslashes($$formname) . '">';
}
    echo '</form>';
?>
</body></html>
?>[/code]
--that creates a page containing only a form with the value of the currently recieved form fields and then auto submits it to a page of your choice
--the notation '$$formname' is called a variable variable
You can also sent a response code of '307' which is a 'temporary redirect' which redirects the form fields automatically as well.  I've tried it before and it works but unless the persons browser security settings  are low, the browser will pop up a warning box. I forget the actual syntax you use, but it is something like this:
[code]<?php
    header("HTTP/1.0 307 temporary redirect");
    exit;
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.