Page 1 of 1

Setting data to $_POST without using a form. Is it possible?

Posted: Tue Mar 01, 2005 12:50 pm
by batfastad
Hi

I was wondering whether it's possible to set data into the POST array to be transferred between pages, without using a form?

I've just tried this on a blank test page...

Code: Select all

<?php
$_POST = array();
$_POST&#1111;"test"] = "test data";
?>
<a href="test4.php">go</a><br />
<br />
<?php
echo($_POST&#1111;"test"]);
?>
And it appears that you can set the POST array within the page, and access the data.
Obviously you may as well just call your array something else to do this.

Then on the next page test4.php...

Code: Select all

<?php
print_r($_POST);
?>
Obviously doesn't return the data that I set on the previous page.

What I'd like to know is if there's a way to set the post data on one page, then access it on a subsequent page.
I guess it's down to how you switch to the next page - i'd like to be able to do this by just the user just clicking a link.

Just wondered if it is possible.
As I want to have data passed between pages, but I don't want to use the address bar $_GET data. And there will be quite a few variables I'll need to pass between pages, each with a large amount of data.

If it isn't possible then no problem - I'll just use sessions.

Is it possible though?

Thanks

Batfastad

Posted: Tue Mar 01, 2005 1:03 pm
by feyd
why not use sessions?

Posted: Tue Mar 01, 2005 1:35 pm
by batfastad
I know sessiosn make sense but the way the site's been designed at the moment means I don't have access to the code at the top of the page, meaning I can't use session_start()

Just wondered if there was a way to do it using POST data to avoid a whole load of work undoing the previous "designer's" work.

Sessions are the way to go.
I have not actually used sessions before, but I have a good understanding of how they work and they don't seem complicated to learn.

Is there a way to do this?

Thanks

Batfastad

Posted: Tue Mar 01, 2005 1:40 pm
by feyd
there's no real way to do it that I am aware of if you can't do sessions, you can't do cookies.. you can't use their ip as they could be running through a NAT.. so unless you pass it through the url ($_GET) nope.

Posted: Tue Mar 01, 2005 2:41 pm
by batfastad
Sessions it is then!

Thanks for clearing that up for me.
Looks like I can charge a nice redesign fee for the work in that case.
:lol: :lol:

Batfastad