Jump to content

how to prevent user direct log in *.php files?


zgkhoo

Recommended Posts

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..

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.