+ 1

Can I use js variables in Php?

Can I use js variables in Php? For example,I want to set text from textarea tag to session by using php and copy it to another textarea tag from another page.

24th Jul 2018, 6:06 PM
Fury
2 Respuestas
+ 6
You need to use ajax for that. var xml = new XMLHttpRequest(); xml.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xml.open("POST", "textarea.php", true); xml.send("data=" + document.getElementById("textarea").value); textarea.php <?php session_start(); $_SESSION["textarea"] = $_POST["data"]; ?> untested
24th Jul 2018, 6:29 PM
Toni Isotalo
Toni Isotalo - avatar
0
Big thanks
24th Jul 2018, 6:43 PM
Fury