Jump to content

session help


fazzfarrell

Recommended Posts

I have create these sessions, exacly the same way on one page

<?php
session_start();
$postConn = $HTTP_POST_VARS['DelCon'];

$_SESSION["postConn"] = $postConn;
?>
<?php
session_start();
$curNcy = $HTTP_POST_VARS['curEncy'];

$_SESSION["curNcy"] = $curNcy;
?>

The $postconn works fine, but the $curNcy does not bring back the desired result?

any one help
Link to comment
Share on other sites

If i put it in like this:
<?php
session_start();
$postConn = $HTTP_POST_VARS['DelCon'];

$_SESSION["postConn"] = $postConn;
?>
<?php
session_start();
$curNcy = "British Pounds";

$_SESSION["curNcy"] = $curNcy;
?>

it returns 'British Pounds'

But I need it to come from a drop down called 'curEncy' to get the value
Link to comment
Share on other sites

the code for the form

<form id="frmCurr" name="frmCurr" method="post">
<select name="curEncy" id="curEncy" onchange="UpdateQuantity()">
<option Selected="True"><?php echo $_SESSION['curEncy']; ?></option>
<option value="British Pounds">British Pounds</option>
<option value="American Dollars">American Dollars</option>
<option value="Euros">Euros</option>
</select>
</form>
Link to comment
Share on other sites

[code]
<?
print $_POST['curEncy'];
?>
<form id="frmCurr" name="frmCurr" method="post" action="">
<select name="curEncy" id="curEncy" onchange="UpdateQuantity()">
<option Selected="True"><?php echo $_SESSION['curEncy']; ?></option>
<option value="British Pounds">British Pounds</option>
<option value="American Dollars">American Dollars</option>
<option value="Euros">Euros</option>
</select>
<input type="submit" value="Submit"/>
</form>
[/code]

For me this code worked.
Link to comment
Share on other sites

I have re-created these sessions

<?php
session_start();
$postConn = $HTTP_POST_VARS['DelCon'];
$_SESSION["postConn"] = $postConn;

$curNcy = $HTTP_POST_VARS['curEncy'];
$_SESSION["curNcy"] = $curNcy;
?>


that now get there values from:

<form id="frmCurr" name="frmCurr" method="post">
                    <select name="curEncy" id="curEncy" onChange="document.frmCurr.submit();">
                      <option Selected="True"><?php echo $_SESSION['curNcy']; ?></option>
                      <option value="British Pounds">British Pounds</option>
  <option value="American Dollars">American Dollars</option>
  <option value="Euros">Euros</option>
                      </select>
                                                      </form>                  </td>
                </tr>
                <tr>
                  <td align="left" valign="middle" class="FormIntroText">Country </td>
                  <td align="left" valign="middle" class="FormIntroText"><form id="frmBasket" name="frmBasket" method="post">
                    <select name="DelCon" id="DelCon" onChange="document.frmBasket.submit();">
                      <option Selected="True"><?php echo $_SESSION['postConn']; ?></option>
                      <option value="UK">UK</option>
  <option value="AGUILLA">AGUILLA</option>
  <option value="ALBANIA">ALBANIA</option>

But the problem is that when you make a seletion from one of the menus it works, change the next option that works but deletes the other sesson?
Link to comment
Share on other sites

You have to make a check if the variable that comes from the forms are not empty, and if these are not than to create the session vars, try this:

[code]
<?
session_start();
$postConn = $HTTP_POST_VARS['DelCon'];
if ($postConn != '')
$_SESSION["postConn"] = $postConn;

$curNcy = $HTTP_POST_VARS['curEncy'];
if ($curNcy != '')
$_SESSION["curNcy"] = $curNcy;
?>
[/code]
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.