Posting VARS via PHP header?
Moderator: General Moderators
-
aluminumpork
- Forum Newbie
- Posts: 14
- Joined: Mon Oct 24, 2005 8:54 pm
Posting VARS via PHP header?
I'm looking for a way to post variable to a page via PHP. It has to POST like a normal form does though, POST while redirecting to the page. Posting in the background via fopen (or similar) is of no use to me.
I can't pass via get (header('Location: page.php?variable=data')) because this is data sensitive. Is there a way to do with without any javascript?
Thanks.
I can't pass via get (header('Location: page.php?variable=data')) because this is data sensitive. Is there a way to do with without any javascript?
Thanks.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
aluminumpork
- Forum Newbie
- Posts: 14
- Joined: Mon Oct 24, 2005 8:54 pm
-
brendandonhue
- Forum Commoner
- Posts: 71
- Joined: Mon Sep 25, 2006 3:21 pm
POSTing to a page is going to return you the contents of that page. It sounds like you might be trying to send POST data from within PHP, and then redirect the client's browser or something like that?aluminumpork wrote:Thanks. Before I look into those libraries though, can any of those post to a page AND redirect to it at the same time?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Posting VARS via PHP header?
From the original poster's original post:
aluminumpork wrote:I can't pass via get (header('Location: page.php?variable=data')) because this is data sensitive.
-
aluminumpork
- Forum Newbie
- Posts: 14
- Joined: Mon Oct 24, 2005 8:54 pm
Okay, here's the entire issue. I submit a form on page a to php script, the php script grabs data from mysql and then must return the data to the original page. Under normal circumstances, I wouldn't do it this way, but I'm testing out a way to have a fail-safe for AJAX methods. The form (when javascript is enabled) posts to the php script via xmlhttprequest, the php scripts returns the mysql data via xml and javascript makes the necessary changes to the page. If javascript is disabled, the form submits as normal to the php script, currently the php script return the same data (that would have normally been return via xml) with GET (header(Location: originalPage.php?vars)), then original page checks to see if any of the variables exists in GET (but i would prefer POST) and outputs them. Therefore older browsers, text based browsers or people that have javascript turned off get the same page no matter what.
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
-
aluminumpork
- Forum Newbie
- Posts: 14
- Joined: Mon Oct 24, 2005 8:54 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
aluminumpork
- Forum Newbie
- Posts: 14
- Joined: Mon Oct 24, 2005 8:54 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
why not something like?
If bar.php is invoked with ?xmlrequest=true it sends the ajax-version, if there's no such GET parameter it sends the complete html document.
Code: Select all
<html>
<head>
<title>---</title>
<script type="text/javascript">
function foo() {
...
xmlHttp.open("post","bar.php?xmlrequest=true",true);
xmlHttp.send(data);
return false;
}
</script>
</head>
<body>
<form method="post" action="bar.php" onsubmit="javascript:foo()">
<input type="text" name="xyz" />
<input type="submit" />
</form>
</body>
</html>If bar.php is invoked with ?xmlrequest=true it sends the ajax-version, if there's no such GET parameter it sends the complete html document.