unable to retain session variables<

liunx

Guest
I am trying to retain a session variable in PHP4 from a form across multiple pages.

<?php
// page1.php
session_start();
header("Cache-control: private");
echo 'Welcome to page #1';
?>
<form name="tester" id="tester">
<input type="text" name="plow" id="plow" value=" <?php if (isset($HTTP_POST_VARS["plow"])) { echo stripslashes($HTTP_POST_VARS["plow"]);}; ?> ">
</form>
<a href=http://www.htmlforums.com/archive/index.php/"file2.php">page 2</a>

<?php
// page2.php
session_start();
header("Cache-control: private");
echo 'Welcome to page #2<br />';
echo $_SESSION['plow']; // something put in from the form
?>

--now what i do not understand is that on page2 nothing shows up on the browser. If i put Anthony in the form and hit the link, obviously i am expecting it to display Anthony on the page2. Is there something i am not doing right?
--I have noticed that if i add a part under the form on page1 before the link <?php $_SESSION['plow'] = 'Anthony'; ?> then it puts Anthony on page2 but ONLY if i use the '' around a difinitive. I am hoping to use a variable.

Can anyone help or see the problem that i do not?

thx,
AnthonyOk 1 think i forgot to mention: make
==page 1 go to a page 3 (just basic html nothing special) &
==page 3 call page 2 (which should return the session variables)

basically this way there is something else that interferes with that system. The idea is that i would like to call that session information at a later point in time. Is that possible?

Anthonythe form data isn't being sent...

1. there is no method defined in the form:
<form action='page2.php' method='post'>

2. There is no button to submit the form:

<form action='page2.php' method='post'>
<button type='submit' name='submit' value='submit'>
Submit
</button>
</form>

3. the results in page 2 are access from the POST variables:

echo $_POST['plow']


4. this could be put into a session variable for use on other pages:

$_SESSION['plow'] = $_POST['plow']OMG thank you so much. I cannot believe i missed that 'Method' issue. The 'Submit' button i just didn't put in because another side didn't use it but now i see why, they were setting the $_SESSION variable to a constant ... $_SESSION['somename'] = 'doggie' which constitued a no need for a submit button since they were not posting anything. I guess i was typing too fast and copied ideas from some other sites so i must not have paid attention.

Now is there anything else i might need to know about the $_SESSION variables before i go and try this? I do know that it will be cleared out once they close the browser, but can i set a session_unset() to my homepage and all other pages that do not use or reference the form to clear it all out? The reason I say this is because when they get to this form (step 1) they are then sent to another website on the same browser screen (step 2) then on return accepted i have them coming back to my site where i will use those session variables to submit the form in the end (step 3). After step 3 OR if step 2 is cancelled i want ALL the session variables cleared.

Does that make sense?

Anthony$_SESSION['plow'] = "";
unset($_SESSION);Thank you for your help so far, I only have one last part that isn't being accepted to work. Most of the other stuff worked but i just kept forgetting the basics.


Alright - Upon making the little changes and supplying enough echo's to display everything it all seems to work. KINDA...

Here is my problem at this point and please let me know your idea.
I have a register page (listing courses) --- Works Good
Link has you fill out form (registerForm) --- Works Good
Submit takes you to Paypal to pay (values from registerForm populate Paypal if they do not have an account --- Works Good
NOW :mad: on the return from Paypal (either return or cancel_return) it is suppost to return to my thankyou.php page (ALL using the same browser), however on the return there are no longer any session values (EVERYTHING is blank)!!!!

:poke: I thought $_SESSION values stayed until either cleared manually or you close the browser!

:dunce: Should I use Cookies in this situation and if so how do i code that? I was trying but different sites kept telling me to do it different ways and it wasn't working in some situations and others did not make sense.

Anthonysession variable get cleaned up after the cleanup process does it in the server. about 30 minutes

if you go to paypal, then it will post all the stuff to your thankyou page. don't worry about sessions. you have to rely on paypal to send you the POSTed from stuff the user did at paypal.Scoutt -- take a look at this. Any echos you see out of the norm at the top of the screen are just to see if it is storing and returning the values from the forms.

website to look at session (<!-- m --><a class="postlink" href="http://www.aceitce.com/FEG/cma.php">http://www.aceitce.com/FEG/cma.php</a><!-- m -->)

At this point of the site is a course list -- click any one of the 3. It takes the variables and stores them in a form_values.php =
1. $_SESSION['first_name'] = $_POST['first_name']; (ETC..)

You link to the registerForm.php which after you press submit again stores the data in the form_values.php = (works good).

Paypal pulls up and everything there is fine. If you cancel or even put the info in there: (since it is development of paypal) I don't think you can use it because you would need my passwords to start up the initial developers version. (again works fine) -- to see it working properly you can just drop me a line on yahoo IM = aceman_777 and i can give you the codes to access it to see the final thankyou.php results (or lack thereof) if you feel the need.

However, when you finish with Paypal (either by paying or cancelling) it sends you to the thankyou.php and i have all echos there for both $_SESSION and $_POST of all variables just to see if anything was retained and the entire screen (aside from the shell) is blank. NOT ONE of the $_SESSION variables stayed as if they were erased and i know for a fact the code isn't set like that.

It's not possible that Paypal somehow erases ones sessions is there? In your opinion? Paypal in itself sends absolutely nothing to my site, all form info is strictly stored and retrieved on my site

Anthonypaypal sends you the info you need through IPN? if this is the case the info is sent behind the scenes and the user never sees it.

I use sessions on my sites and it comes from paypal and it works just fine. if you are loosing them than the timeout is set to low, that would be my guess.

ok, look at it this way. when you register you go straight to paypal, you can't have any sessions saved if paypal takes the post. correct??? so yes, your session variables will be empty cause you never get a chance to set them.ok i do see what you are saying.

What do you suggest i do? or how to do it?

I would like to submit the values to a php file that stores all the values from the form. This way my thank you form can just submit the values to the email afterwards.

Anthony

I appologize because I am at the end of this piece and I feel like I don't have enough knowledge to finish what I logically see as easy.
 
Back
Top