store value of input type=”hidden” into a php variable.
The value is set by javascript into a hidden variable[input].
Now i need to save its value into a $myphpvariable.
I cant set the value into session with javascript and cookies is not an option.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
After the page is submitted, hidden input elements will show up in the
$_POSTsuperglobal, just like any other form element. If the hidden form field were calledcoolsecretthen the value would be in$_POST['coolsecret'](or$_GET['coolsecret']if you usedmethod=get).Before the page is submitted, there’s no way to get a value from javascript into PHP, because your PHP code is all executed on the server, and the javascript isn’t executed until the user has loaded the page on their computer. You should think about what you’re trying to accomplish, and whether there’s any way to compute the variable you want in PHP instead. If it’s absolutely impossible to compute the variable ahead of time, then like Another Code said, you’ll need to use something like an AJAX request.