zgkhoo Posted October 12, 2007 Share Posted October 12, 2007 hi, may i know how to prevent user direct log in *.php files? eg the user can directly log in the page by key in eg: http://localhost//changepass.php in the browser which he/she no need to log in to the system at all using username n password. anyone know how to prevent it? thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/72917-how-to-prevent-user-direct-log-in-php-files/ Share on other sites More sharing options...
MasterACE14 Posted October 12, 2007 Share Posted October 12, 2007 you can check if a $_POST has been set from your login page. If it hasn't, redirect them to the login page. Like this: <?php if(!isset($_POST["username"] || !isset($_POST["password"]) { header("Location: http://www.yoursite.com/login.php"); } else { header("Location: http://www.yoursite.com/users_page.php"); } ?> Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72917-how-to-prevent-user-direct-log-in-php-files/#findComment-367748 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.