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
https://forums.phpfreaks.com/topic/24098-session-help/
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
https://forums.phpfreaks.com/topic/24098-session-help/#findComment-109545
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
https://forums.phpfreaks.com/topic/24098-session-help/#findComment-109561
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
https://forums.phpfreaks.com/topic/24098-session-help/#findComment-109713
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
https://forums.phpfreaks.com/topic/24098-session-help/#findComment-109897
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
https://forums.phpfreaks.com/topic/24098-session-help/#findComment-109929
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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