Jump to content


Photo

session help


  • Please log in to reply
12 replies to this topic

#1 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 16 October 2006 - 02:22 PM

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

#2 dymon

dymon
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 16 October 2006 - 02:34 PM

$curNcy = $HTTP_POST_VARS['curEncy'];

maybe the var curEncy should be curNcy. Or check what does the $HTTP_POST_VARS['curEncy'] return.
Web is the future ... desktop will die ...

#3 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 16 October 2006 - 02:49 PM

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

#4 dymon

dymon
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 16 October 2006 - 02:58 PM

Show the code of the form from where you send the variable curEncy, with the drop down component.
Web is the future ... desktop will die ...

#5 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 16 October 2006 - 03:00 PM

Why not just use:
<?php
session_start();
$_SESSION["postConn"] = $_POST['DelCon'];
?>
and
<?php
session_start();
$_SESSION["curNcy"] = $_POST['curEncy'];
?>


#6 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 16 October 2006 - 03:06 PM

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>

#7 dymon

dymon
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 16 October 2006 - 08:18 PM

<?
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>

For me this code worked.
Web is the future ... desktop will die ...

#8 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 16 October 2006 - 08:35 PM

thanks

only problem is they dont want a submit button!

#9 dymon

dymon
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 16 October 2006 - 08:39 PM

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?
Web is the future ... desktop will die ...

#10 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 16 October 2006 - 09:27 PM

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>

#11 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 17 October 2006 - 08:34 AM

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?


#12 dymon

dymon
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 17 October 2006 - 09:59 AM

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:

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

$curNcy = $HTTP_POST_VARS['curEncy'];
if ($curNcy != '')
	$_SESSION["curNcy"] = $curNcy;
?>

Web is the future ... desktop will die ...

#13 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 17 October 2006 - 10:11 AM

Quality, works a treat thank you!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users