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! Link to comment https://forums.phpfreaks.com/topic/208695-hi-everyone/ 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 Link to comment https://forums.phpfreaks.com/topic/208695-hi-everyone/#findComment-1090313 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. Link to comment https://forums.phpfreaks.com/topic/208695-hi-everyone/#findComment-1090316 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. Link to comment https://forums.phpfreaks.com/topic/208695-hi-everyone/#findComment-1090324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.