Jump to content

Recalling Session Variables throughout site


oddball25

Recommended Posts

Hey

 

I cannot seem to recall my session variables throughout my site and i cannot see where i am going wrong.

 

I have variables in my flash file which i have posted into my 'info.php' all working fine, i declare the post variables in 'info.php' with the following:

 

[b]$num[/b] = $_POST['number'];
[b]$choice[/b] = $_POST['choice'];
[b]$colour[/b] = $_POST['colour'];

 

These variables then get called in a simple form that is echo'd as below:

 

echo '<div id="info">
    <form name="form" method="post" action="">
    <table width="450" border="0" cellspacing="1" cellpadding="3">
    <tr><td width="65%"><strong>Number</strong></td>
    <td width="65%"><strong>Choice</strong></td>
    <td width="20%"><strong>Colour</strong></td>
    <td width="15%"><strong>Quantity</strong></td></tr>
    <tr><td>[b]'.$num.'[/b]</td><td>[b]'.$choice.'[/b]</td><td><input type="text" name="colour" value="[b]'.$colour.'[/b]"readonly></td>
    <td><input type="text" name="qty1" size="5" value="1"> </td></tr>
    <tr valign="bottom"><td><br>Paying with: <br>
    <input type="radio" name="x" value="CashPayment" checked="checked">Cash<br>
    <input type="radio" name="x" value="CardPayment">Card</td>
    <input type="submit" name="Submit" value="Submit"></td></tr>
    </table>
    </form>';

 

I then set the post variables to session variables with the following:

 

$num = $_POST['number'];
$choice = $_POST['choice'];
$colour = $_POST['colour'];
        [b]$_SESSION['num'][/b] = $_POST['number'];
[b]$_SESSION['choice'][/b] = $_POST['choice'];
[b]$_SESSION['colour'][/b] = $_POST['colour'];

 

So the form has the session variables stated as in:

 

echo '<div id="info">
    <form name="form" method="post" action="">
    <table width="450" border="0" cellspacing="1" cellpadding="3">
    <tr><td width="65%"><strong>Number</strong></td>
    <td width="65%"><strong>Choice</strong></td>
    <td width="20%"><strong>Colour</strong></td>
    <td width="15%"><strong>Quantity</strong></td></tr>
    <tr><td>[b]'. $_SESSION['num'].'[/b]</td><td>[b]'. $_SESSION['choice'].'[/b]</td><td><input type="text" name="colour" value="[b]'. $_SESSION['colour'].'[/b]"readonly></td>
    <td><input type="text" name="qty1" size="5" value="1"> </td></tr>
    <tr valign="bottom"><td><br>Paying with: <br>
    <input type="radio" name="x" value="CashPayment" checked="checked">Cash<br>
    <input type="radio" name="x" value="CardPayment">Card</td>
    <input type="submit" name="Submit" value="Submit"></td></tr>
    </table>
    </form>';

 

I have

<?php
session_start();

At the top of every php page.

 

Can anyone help me with what i am doing wrong? The variables display when you first go to 'info.php' but as soon as you navigate away and then back the fields are empty.

 

Any ideas?

 

Many thanks

 

Jon

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.