dadamssg Posted January 18, 2009 Share Posted January 18, 2009 i want to keep what a user inputs in my form in a session variable so i can transfer it over to a page where he can then check what he inputs before submitting to my database. how do i store the POST variables into a session variable to use in the next page? this isn't working $_SESSION['$_POST['$title']]= $title; the name for the input field is 'title' Quote Link to comment https://forums.phpfreaks.com/topic/141311-session-variable-q/ Share on other sites More sharing options...
Daniel0 Posted January 18, 2009 Share Posted January 18, 2009 Don't you mean $_SESSION['title'] = $_POST['title']; ? The other thing doesn't make sense... Quote Link to comment https://forums.phpfreaks.com/topic/141311-session-variable-q/#findComment-739623 Share on other sites More sharing options...
RussellReal Posted January 18, 2009 Share Posted January 18, 2009 $_SESSION['$_POST['$title']]= $title; ok.. idk you obviously don't see whats wrong with this picture, however I'll risk losing first post in order to FULLY explain it to you lol ofcourse you'd use the superglobal $_SESSION but you started a single quote which would denote a literal text value would follow, then terminated by another single quote.. E.G. $_SESSION['literalTextValue'] however you are doing 2 things wrong here literal strings do not evaluate variables for starters secondly you forgot a terminating quote (') My advice for you here, is to always when you're expecting to write a string, automatically write two quotes, instead of just 1 before, and 1 after.. this way you can never make this mistake again. for the variable, you need to know that that will never work and would probably not be the best option for you! plain and simple $_SESSION['title'] = $_POST['title']; would do just fine.. please don't just copy/paste the aboev.. try and know exactly why your script wasn't working, and never make the mistake again.. Happy Coding - Russell Quote Link to comment https://forums.phpfreaks.com/topic/141311-session-variable-q/#findComment-739625 Share on other sites More sharing options...
dadamssg Posted January 18, 2009 Author Share Posted January 18, 2009 i think thats it but why am i getting another error when im trying to call that variable later? any ideas? <?php /* File: checkpost.php*/ include("caneck.inc"); session_start(); $_SESSION['title'] = $_POST['title']; $_SESSION['description'] = $_POST['description']; $_SESSION['event'] = $_POST['event']; echo "<table border='7'> <tr> <td><b>Title: </b></td><td>$_SESSION['title']</td> </tr> <tr> <td><b>Description: </b></td><td>$_SESSION['description']</td> </tr> <tr> <td><b>Event Type: </b></td><td>$_SESSION['event']</td> </tr> <tr> <td colspan=2><center><form action='submitpost.php' method='POST'><input type='submit' name='post' value='post'> </center></form> </td> </tr> </table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/141311-session-variable-q/#findComment-739628 Share on other sites More sharing options...
trq Posted January 18, 2009 Share Posted January 18, 2009 What is this other error? Quote Link to comment https://forums.phpfreaks.com/topic/141311-session-variable-q/#findComment-739658 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.