Update PHP Session with form value on page after JQuery function
Hopefully final question about sessions.
A page loads with data from a form. Some of the data is taken by a session for the next page. Meanwhile on this page a form field called 'GT_specifications' is inside a form. It s data is updated towards the end of the page with a JQUERY script that puts .html() of a div inside it. This value then needs to go into the SESSION as well. I tried
<?php $_SESSION['booking-form-specifications'] = $_POST['GT_specifications'] ?>
after the script is activated at the bottom of the page but it did not work.
Any ideas?
Marvellous
CLARIFICATION "DID NOT WORK"
The value of GT_specifications does not go into the session as on the other side the echo of $_SESSION['booking-开发者_如何学Pythonform-specifications']
does not equal the value of GT specifications when the session is recalled. All other sessions are working fine. The value of $_SESSION['booking-form-specifications']
has to be taken from a form field on this page not loaded in on load and I think that is the problem. So $POST['GT_specifications']
is wrong as that field has not be posted. We need to get the value of the field named 'GT_specifications']
on this page not one posted in.
You forgot to call session_start();
I'm not sure i understand your question.
Do you update the page with javascript before submitting? Or do you do it after, if you do it after - why use javascript to change the content at all, could just do it with PHP when you serve the page.
If you do it with javascript before an actual submit, you can't set a session. A session needs to happen serverside and would happen before the page is served to the browser - you cannot combine javascript and a php session without submitting this data to the server and then saving (via AJAX or form submit)
精彩评论