Jump to content

saving $_POST variables


acidglitter

Recommended Posts

on one of my pages it checks if there is a $_POST variable and a session variable set. if the session variable isn't set then the page automatically refreshes by going to the same url again (but then it loses the $_POST variable). how can i also keep the $_POST variable doing that? isn't there a way to send it?

Link to comment
Share on other sites

okay but now for some reason its not getting the saved sessions. whats happening is someone is buying something, then coming back to the site from paypal. on the first time they come back, their member id (saved as a session) is missing. so the page refreshes to get the member id. i tried using header("Location: page") and i just barely tried with html like <meta http-equiv="refresh" content="0;url=page"> but neither will work. what would solve basically everything would be if i could just get the member id saved without having to refresh the page first.

Link to comment
Share on other sites

Why is their member ID missing?  How are you saving it/accessing it?

 

Also, for your information, you can't redirect POST data like that.  You can make another POST request to the next page with cURL, but that's completely different than what you're trying to do.

Link to comment
Share on other sites

You need to make sure you are coming back to the same domain that the session was set on, ie www.mysite.com or mysite.com.  The session will remain until the browser is closed or times out (24 mins by default).

 

i'm saving it in a session. normally to get it you would go $_SESSION['member_id']. but because you leave the site to go to paypal, that session kind of temporarily ends, then when you come back you need to refresh the page to get it back again..

Link to comment
Share on other sites

<?php
// Keep this at the top of ur pages
session_start();
?>

 

<?php
// Create the form
echo "<form action=\"\" method=\"post\"><input name=\"fieldname\" type=\"text\" size=\"8\" maxlength=\"12\" /></form>";
?>

 

<?php
// Call the forms variables and store them into a session array
$fieldvar = $_POST['fieldname'];
$_SESSION['fieldname'] = $fieldvar;
?>

 

<?php
// Call the session back to the document
$fieldname = $_SESSION['fieldname'];
echo "The field is " . $fieldname;
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.