jeni jeni - 8 days ago 5
PHP Question

How to pass the value of javascript into a PHP variable and stored into mysql database?

How to get javascript variable value in PHP and php value stored in to database.

if my JS code like

age = new Date().getFullYear()-getYearInteger();


This code o/p 2016-(yearofbirth). I am getting output correct in JS. How to store this age value in MySQL database.

Answer

In order to save JS value to a PHP variable you need to make a server call.

You can easily do the vice versa though like this:

var jsVariable = '<?= $php_variable ?>';

Have an ajax call, send the data to server side and store in variable.

Comments