title: To store JavaScript variable output into a PHP variable and to database?
body: <p>I am able to get javascript variable output into php variable,but i am not able to store php variable value stored from javascript variable into database its storing the whole script for eg:</p>
  
  <pre><code>&lt;script&gt;document.write(answer)&lt;/script&gt;
  </code></pre>
  
  <p>I tried on update to redirect on registration page but it remain static on the same page.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>if(isset($_GET['status'])) 
  {
  if($_GET['status']=="Rejected")
  {
  echo("&lt;script type='text/javascript'&gt; var answer = prompt('Please enter'); &lt;/script&gt;");?&gt;
  &lt;script&gt;var a = document.write(answer);
  window.location.href = window.location.href+'#reason='+answer;&lt;/script&gt;
  &lt;?php
  if(isset($_GET['reason']))
  {
  $reason=$_GET['reason'];
  $approve="UPDATE approveleave SET status='Rejected',rejectreason='".$reason."' WHERE id='".$id."'";
  $result2=mysql_query($approve,$con);
  header("location:registration.php");
  }
  }
  }   
  ?&gt;
  </code></pre>
  
  <p>Any solution will be appreciated.</p>
  
  <p>Thanks</p>