Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Hidden Input, Image Buttons, and SESSION Variables

session session variable

  • Please log in to reply
1 reply to this topic

#1 makamo66

makamo66

    CC Newcomer

  • Just Joined
  • PipPip
  • 18 posts

Posted 12 May 2010 - 03:02 PM

I have a very simple survey at Project Potluck The survey is three pages long and on each page there is hidden variable which calculates how many bonus point the user has accumulated based on the number of good answers and passes the total to the next page. Instead of using a submit button, I am using an image button but I believe they are equivalent. For example for one of the survey pages I have the following code inside of the form tags:

<input type="hidden" name="bonus" value="<?php
$bonus == $_POST['bonus'];
if ($_SESSION['cooking'] == 'hobby')
$bonus += 1;
echo $bonus; ?>">

It collects the bonus posted from the previous page and adds one more bonus point if $_SESSION['cooking'] == 'hobby' After it adds or doesn't add the bonus point, the hidden value gets submitted to the next page. For some reason this code used to work before I made some improvements to the code and after "improving" the code it stopped working. Before I improved the code I wasn't using SESSION variables or image buttons. Any idea how this can be fixed?
  • 0

#2 makamo66

makamo66

    CC Newcomer

  • Just Joined
  • PipPip
  • 18 posts

Posted 12 May 2010 - 03:08 PM

Oh and another key change was that the form became self-submitting (that is, <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">) and after being posted to itself, it gets sent to the next page via a header, that is it gets sent with header("Location: $url");.
  • 0





Also tagged with one or more of these keywords: session, session variable

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download