+ 2

Set a $_POST value

Hello, I have an html form which has one input with the name "msg". However I need to add another attribute which is set by javascript so I can access it through $_POST[] as well. How can I do this?

28th May 2018, 12:26 PM
Gleb Koval
Gleb Koval - avatar
4 Réponses
+ 16
Attributes are not accessible via $_POST object. The name attribute is only used to define the key for the input value.
28th May 2018, 12:46 PM
Toni Isotalo
Toni Isotalo - avatar
+ 11
The only way would be ajax requests.
28th May 2018, 6:08 PM
Toni Isotalo
Toni Isotalo - avatar
+ 3
Still how can I access any javascript variable with php? In anyway there is, I just want to pass information.
28th May 2018, 1:11 PM
Gleb Koval
Gleb Koval - avatar
+ 3
you can use <form action=response.php> <input type=text name=message> and after submitting the form via get or post u can use $_GET['message'] or $_POST['message'] to get the input from user ... you cant really use JavaScript variable to php ..
28th May 2018, 5:12 PM
Prashanth Kumar
Prashanth Kumar - avatar