Loading ...
Sorry, an error occurred while loading the content.
 

Session Variable

Expand Messages
  • Lokesh M
    Hello, I have a page in which I publish articles and allow visitors to put in their comments. I have put image verification number which generates random
    Message 1 of 1 , Oct 12, 2007
      Hello,

      I have a page in which I publish articles and allow visitors to put in their comments.
      I have put image "verification number" which generates random image and the visitor needs to key in the correct verification code to submit his comment.
      Page works fine and checks for matching "verification number" after submitting the page.

      But I want to validate this "verification number" before submitting the page.
      I am using Javascript and everything is in place and working fine.
      Only glitch is the value of "verification number" which is stored in session variable always has the previous value in its state
      This is causing all user inputs to fail.
      How do i retrieve the latest "verification number" from session variable?

      --------------------------
      <script type='text/javascript'>
      function assignval()
      {
      document.getElementById('xnum').value='<?php echo $_SESSION['random_value'];?>';
      }
      </script>


      Validation Code:<input name='numcode' id='numcodex' type='text' class='input' width='90px'> <=> <img src='randomimage.php' onclick=\"assignval();\">
      Test:<input type='text' name='xnum1' id='xnum' class='input' style='width:230px'>
      --------------------------

      Here
      randomimage.php generates "Verification number"
      function assignval() assigns the value of "verification number" from session variable 'random_value' to dummy field xnum1
      What is happening is on 1st try it is blank
      then i refresh page and click on image, then the previous value of "verification number" is assigned to xnum1
      this continues...
      i.e., xnum1 is assigned the value of previous "verification number"
      How to fix this...


      Regards



      _________________________________________________________________
      Call friends with PC-to-PC calling -- FREE
      http://get.live.com/messenger/overview

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.