How to store javascript variable value in mysql using php

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:

document.write[answer]

I tried on update to redirect on registration page but it remain static on the same page.

Here is my code :

if[isset[$_GET['status']]] 
{
if[$_GET['status']=="Rejected"]
{
echo[" var answer = prompt['Please enter']; "];?>
var a = document.write[answer];
window.location.href = window.location.href+'#reason='+answer;

Chủ Đề