zero-perfoliate
zero-perfoliate

Author Topic: passing $_POST['value'] through several pages  (Read 978 times)

Offline HailDani

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
passing $_POST['value'] through several pages
« on: October 09, 2009, 01:34:36 AM »
Hello all you PHP programmers :) I'm pretty new to PHP, and loving it^^

anyways.. I am trying to pass the input value from page1.php to page2.php - That works. BUT, when I go to page3.php, PHP doesen't remember the input anymore..

http://img35.imageshack.us/img35/1724/phphphphphphp.jpg


I've tried sessions, but with no luck. The thing is, you have to be able to go back and write any other number (S/N) in the input field. So the function I'm going to use must NOT save the value so it can't be changed.

all help appreciated

- Karim

Offline Joshstrange

  • PHP Workers
  • **
  • Posts: 8
  • Karma: +0/-0
Re: passing $_POST['value'] through several pages
« Reply #1 on: October 10, 2009, 05:07:49 PM »
Why did sessions not work? or could you just not get them to work, sessions were designed to fit the exact problem you are having

Offline YuniYasha

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Re: passing $_POST['value'] through several pages
« Reply #2 on: November 22, 2009, 06:36:04 PM »
If you want to pass it to a third page, it'd be best to store the data in a Session or a Cookie.

For sessions, write session_start() at the top of every page, or turn automatic session on in your php.ini
then to write the data:
 $_SESSION['var1'] = "lol i like data!";
To Pull it
$data = $_SESSION['var1'];


If you REALLY want to continue using the post function, you'd have to create a Hidden field, and set the value
Ex:  <input type="hidden" name="mydata" value="lol data!" />
then as long as it's in the form, you can just do $mydata = $_POST['mydata'];
echo $_POST['mydata'] would return "lol data!"

hotnoob

  • Guest
Re: passing $_POST['value'] through several pages
« Reply #3 on: December 04, 2009, 10:02:15 PM »
you could try encrypted $_GET vars instead of $_POST vars.
*i've always had trouble with forwarding POST Vars, it may just be my host.*

here is ann example of how to encrypt ur get var...

$getVar = "Hi! I'm a HotNoob! ohhh hot Damn :D";
$getVar_Enco = base64_encode($getVar); // there are other methods to encoding, but this is the easiest and simplest. i have made encryption protocols by hand before; it's not hard, but i don't want anyone to see them, for security reasons.

<a href='goto.php?data=<?php $getVar_Enco?>'>

Then to decode it,
$getVar_Enco = $_GET['data'];
$getVar_Deco = base64_decode($getVar_Enco);

For the most part, base64 encoded data is compatible with sending by get vars, i have had no real problems with it so far.

hope i helped :D

Offline teamatomic

  • PHP Workers
  • **
  • Posts: 17
  • Karma: +0/-0
    • Cool Chef
Re: passing $_POST['value'] through several pages
« Reply #4 on: December 10, 2009, 06:34:56 PM »
Sessions is the way to go to keep persistent. You can use POST and hidden input in a form but you need to use JS to trigger it on leaving the page which is not as reliable as a session.


HTH
Teamatomic
When in doubt...ski fast
When scared...ski faster
When terrified...point em down

Offline RoseKnight

  • PHP Help Guru's
  • ****
  • Posts: 52
  • Karma: +0/-0
Re: passing $_POST['value'] through several pages
« Reply #5 on: March 19, 2010, 07:01:11 PM »
What is your code? your output tells us nothing without your code behind it.

 

zero-perfoliate