Echo a PHP Session
I have a form that is supposed to store some of its data into a session. For开发者_StackOverflow社区 the purpose of this example.
This information is then collected on another page.
<?php
session_start();
print_r($_SESSION['booking-form']); ########### for debugging purposes ###########
if ($_SESSION['booking-form']) {
echo $_POST['GT_title']
?>
<!DOCTYPE html>
<html>
<?php
}
elseif ($_SESSION['booking-form']) {
}?>
</html>
Now although the debug is working the echo is not working ie. echo S_POST['GT_title'].
- How do I echo the information on the second page.
- Can I echo it wherever I want it in the html (ie. in the middle of the body somewhere with
- On the first page some data in the form can be changed with options. This would need to update the session before the page is changed.
CLARIFICATION
For the purpose of a booking form. The user filled in a series of options that were then echo'd on the next page. At this point they need to log in so the form data must enter into a session. The session data should then be returned on a third page.
1) what information? $_POST['GT_title']
would refer to a form element, presumably on the previous page. Does it exist? Is it filled in? what are you expecting?
2) You can echo
where ever you like.
3) clarify? you can update a session with post values easily.
$_SESSION['foo'] = $_POST['bar']
your question isn't really that clear.
You can echo it wherever you want but if it doesn't exist or doesn't have a value then it might appear to be not working. To know for sure use var_dump($_POST['GT_title']);
For your echo question: Are you sure that GT_title is set? Posting the form on your previous page might help.
You can echo wherever you want, you can just put
<?=$varname?>
anywhere in your html.
You can also update your session wherever you want.
$_SESSION['abc'] = value;
echo '<pre>';
print_r($_POST);
echo '</pre>';
Print it after your header. I hope this helps a little :)
精彩评论