timmymwd Posted January 13, 2010 Share Posted January 13, 2010 Hey everyone, What was supposed to be a quick check that my logout link was working has turned into a headache. Here's the link: <a href="functions.php?action=logout">Logout</a> Here's the file it calls: <?php switch($_POST['action']){ case 'logout' : session_start(); session_destroy(); header("location:index.php"); break; default: echo "unknow action!\n"; } ?> And here's the error log: [2010-01-13 13:57:14]: error: file is writable by others: (/home/royersmw/public_html/test/functions.php) [2010-01-13 13:53:24]: error: file is writable by others: (/home/royersmw/public_html/test/functions.php) [2010-01-13 13:36:19]: error: file is writable by others: (/home/royersmw/public_html/test/functions.php) [Wed Jan 13 13:57:14 2010] [error] [client] Premature end of script headers: /home/royersmw/public_html/test/functions.php [Wed Jan 13 13:53:24 2010] [error] [client] Premature end of script headers: /home/royersmw/public_html/test/functions.php [Wed Jan 13 13:36:19 2010] [error] [client] Premature end of script headers: /home/royersmw/public_html/test/functions.php I've not had an issue with anything else. Now - it has been about 4 years since I've done any substantial coding, so feel free to berate me for what I've done. I just want a simple terminate session link - I'm building a small site for my students to use, and I just want it to logout properly so the next round of kids are greeted by the login in screen. My session check on my index.php (if its not defined, kick them to the login page) works out, as does the login. So again - any help would be appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/188375-500-error-calling-php-file/ Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 First of all what your doing won't work, you need to use GET instead of POST, also i improved the session killer, to clear the session, remove the PHPSESSID cookie and then destroy from the server. <?php //switch($_POST['action']){ switch($_GET['action']){ case 'logout' : session_start(); session_start(); $_SESSION = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000,$params["path"], $params["domain"],$params["secure"], $params["httponly"]); } session_destroy(); header("location:index.php"); break; default: echo "unknow action!\n"; } ?> error: file is writable by others This means your permissions are set incorrectly, change then to 755, Premature end of script headers This could be a few things but its normally when a file is used at the wrong type.. it could be related to the header, but would need more details (action's that cause it) Quote Link to comment https://forums.phpfreaks.com/topic/188375-500-error-calling-php-file/#findComment-994464 Share on other sites More sharing options...
timmymwd Posted January 13, 2010 Author Share Posted January 13, 2010 Yeah I saw the post vs get as soon as I copied the code - why is that there's dumb little errors like that instead of big melt down errors? Oh well ... Anyway, thanks for the improved kill session, and for some reason Aptana was uploading the files with restricted permissions, since I just switched to Aptana on this project that would make sense why I hadn't encountered the problem before. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/188375-500-error-calling-php-file/#findComment-994505 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.