jmte Posted July 23, 2010 Share Posted July 23, 2010 Hi, my name is maria-teres, and i am desperate for some help. i hope that one of you can help me to resolve my problem. Lets tell my PHP-story! i have on all my pages <?PHP session_start(); if (!$_SESSION['company_loggedin']) ?> this because i have one menu, one for guests and one for the registred user. this works very fine!! BUT.. then i have som forms. when a user dont fill in a post this messages comes up if (empty($_POST['Name'])) { echo '<script>alert("Please enter your name");</script>'; echo '<script>history.back(1);</script>'; exit(); } else { the problem is that all the inputs will be deleted, so the user have to write all once again. when i take away <?PHP session_start(); if (!$_SESSION['company_loggedin']) ?> the form works fine!. so i dont know what to do? someone? i hope i have explained well. thanks! Quote Link to comment Share on other sites More sharing options...
dezkit Posted July 23, 2010 Share Posted July 23, 2010 change <?PHP session_start(); if (!$_SESSION['company_loggedin']) ?> to <?PHP session_start(); if (!$_SESSION['company_loggedin']){ echo "not logged in"; //header("Location: index.php"); } ?> btw- post more code if this doesnt work Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 When you include code in your posts do this: [code=php:0] ... your php code here [/code] And it will look the way dezkit's reply to you looked, which is easier for everyone to read. Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 Using the browser history is not the way to handle that problem. What you should do, is store their $_POST input into a session variable. In the form you can read that out of the session (if it exists) and repopulate the form using html. Quote Link to comment 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.