Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Abd
    Abd is offline
    New Coder
    Join Date
    Aug 2002
    Location
    Lagos, Nigeria
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Password Protection

    Hi All,

    please does any one have a code on password protection that checks username and password in a Database before displaying the required web page

    Abd
    Abdul

  • #2
    New to the CF scene
    Join Date
    Oct 2002
    Location
    Israel - Rishon Lezion
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    here i use this piece of code...

    in my administration portion of every project:

    PHP Code:
    <?php
    if(isset($_POST['submit'])) { // true if form has been submitted
    session_start();
    include(
    "./System/backend.inc");
    $password base64_encode($password);
    $q "SELECT AdminID FROM admins WHERE Username='$username' AND Password='$password' ";
    $security db_query($q);

    if(
    mysql_num_rows($security)) {
    list(
    $sequrity_id) = mysql_fetch_row($security);

    $sess_security_id $security_id;
    session_register('sess_security_id');
    header("location: ./entry_page.php");
    }

    // authorization not successful show form again...
    }

    ?>
    <html>
    <head>
    <link REL="StyleSheet" HREF="../style.css" TYPE="text/css">
    <title>Authorization.</title>
    </head>
    <body>
    <form action="<? echo $PHP_SELF?>" method="post">
    <font class="content">Username : <input type="text" name="username"><br>
    Password: <input type="password" name="password"><br>
    <input type="hidden" name="submit" value="1">
    <input type="submit" value="Login">
    </form></html>
    and execute this function in every page

    PHP Code:
    function check_id() {
    session_start();
    if(!
    session_is_registered('sess_security_id')) {
    header("location: ./index.php");
    }

    you should first include it, and then execute it.

    Arik


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •