Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default [PHP - Beginner] Simple Secure Login

    This is my first tutorial so I hope I explain it in enough detail.


    <form name="login" method="post" action="protected.php">
    Username:
    <input name="formuser" type="text" id="formuser">
    <br>
    Password:
    <input name="formpass" type="password" id="formpass">
    <br>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset">
    </form>
    Thats the basic Form that has a submit button etc.
    Next make a page called protected.php and enter this code:

    <?php
    $user = "USERNAME HERE";
    $password = "PASSWORD HERE";
    $formuser = $_POST["formuser"];
    $formpass = $_POST["formpass"];
    if(($formuser == $user) && ($formpass == $password)){
    //Protected Content here
    }
    else {
    echo("Login Incorrect, Please click back and try again");
    }
    ?>
    <?php - Starts the php

    $user = "USERNAME HERE"; - That just says that if the username entered is that its true

    $password = "PASSWORD HERE"; - That just says that if the password entered is that its true

    $formpass = $_POST["formpass"];
    if(($formuser == $user) && ($formpass == $password)){
    //Protected Content here
    }
    else {
    echo("Login Incorrect, Please click back and try again");
    }
    ?>

    Unless you know what your doing dont change anything there except the bit in bold

    And voila you have your simple login!


    You don't like me
    Chances are I don't like you.

  2. #2
    Join Date
    Jul 2006
    Posts
    38
    Tokens
    0

    Default

    I swear i seen that before

  3. #3
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default

    Ye it was on Techtuts but I rephrased and tried to explain more


    You don't like me
    Chances are I don't like you.

  4. #4
    Join Date
    Apr 2006
    Location
    West Midlands
    Posts
    3,384
    Tokens
    0

    Latest Awards:

    Default

    [quote=Respect]This is my first tutorial so I hope I explain it in enough detail.

    [quote]

    if its off techtuts its not yours.

  5. #5
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default

    Ye it was on Techtuts but I rephrased and tried to explain more
    Sorry shouldnt of said it was mine I should of said it was techtuts reprhased as mine


    You don't like me
    Chances are I don't like you.

  6. #6
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    With that theyed have to log in each time the viewed the page "/ although im feeling in a tutoraly mood so i may write one...

  7. #7
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    yep use cookies

Posting Permissions

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