Jump to content

Recommended Posts

Gr8 more super noob posts :-)

 

Ok I asked something earlier and kindly got a gr8 answer that I needed to use Sessions using session_start()

 

So thats cool, went and read up on this.

 

Now I am trying to create and pass a variable to the $_SESSION array and Im doing something wrong. 

 

Here's how it goes :

 

page1.php  loads

 

<?php

 

session_start();

 

?>

 

HTML BEGINS. . . .

 

Then try to pass a variable :

 

<a href="page2.php?_SESSION ['duration']=3"><img src="images/Paypal/27.jpg"></a>

 

So I am trying to create an array in the $_SESSION called 'Duration' and make its value '3'  This value I want to be availalbe to the session

 

I have dropped the $ after the '?' as I read that when passing variables in URL's you can negate the $.

 

So when I click the image link :

 

page2.php  loads :

 

I start with :

 

<?php

 

session_start();

$duration = $_SESSION['duration'];

?>

 

HTML BEGINS . . . .

 

I then try to call the value from the 'duration' $_SESSION system variable:

 

<p>You choose to advertise for <?php echo "$duration"; ?> days</p>

 

It just returns blank.  I know this is a total joke for an experienced PHP programer, but if you could correct me that would be great

 

Thanks :-)

 

 

 

 

Thanks for the reply.

 

It seems in the below example here that the variable 'duration' is simply declared as '3' and then latter called upon.

 

What i need to do is have it such that when a user clicks on a specified image it sets a the variable 'duration' to '3'

 

Hope thats clearer, thanks.

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.