invincible_virus Posted December 30, 2006 Share Posted December 30, 2006 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?? Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/ Share on other sites More sharing options...
wildteen88 Posted December 30, 2006 Share Posted December 30, 2006 If you don't want your variables to be shown then store them in a session. You then unset the session when you receive them in xyz.php. Another way is to use a cookie. Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149876 Share on other sites More sharing options...
invincible_virus Posted December 30, 2006 Author Share Posted December 30, 2006 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 ?? Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149879 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149883 Share on other sites More sharing options...
invincible_virus Posted December 30, 2006 Author Share Posted December 30, 2006 don't want to use mod_rewite as I have atleast 15 variables to be sent.. Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149886 Share on other sites More sharing options...
mainewoods Posted December 30, 2006 Share Posted December 30, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149887 Share on other sites More sharing options...
mainewoods Posted December 30, 2006 Share Posted December 30, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149897 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 you could also:[code=php:0]$_GET['name']="value";include "xyz.php";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32287-setting-request-object/#findComment-149904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.