Jump to content

Archived

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

fazzfarrell

session help

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

Share this post


Link to post
Share on other sites
$curNcy = $HTTP_POST_VARS['[b]curEncy[/b]'];

maybe the var curEncy should be curNcy. Or check what does the $HTTP_POST_VARS['curEncy'] return.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Show the code of the form from where you send the variable curEncy, with the drop down component.

Share this post


Link to post
Share on other sites
Why not just use: [code]<?php
session_start();
$_SESSION["postConn"] = $_POST['DelCon'];
?>[/code] and [code]<?php
session_start();
$_SESSION["curNcy"] = $_POST['curEncy'];
?>[/code]

Share this post


Link to post
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>

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
ok than, show the JavaScript code, where the form is submited. Because the form and the POST variables are OK.

Why your form doesn't have an action="" atributte?

Share this post


Link to post
Share on other sites
i think its this

<script Language="VBScript">
Sub UpdateQuantity()

frmBasket.submit

End Sub

Sub DisplayAlert()
Alert("Not currently available in electronic format")
End Sub

</script>

Share this post


Link to post
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?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.