PHP Website

Discussion in 'Web Design & Coding' started by gmagnuson, Jan 18, 2003.

  1. gmagnuson

    gmagnuson Guest

    Would anyone have a php website that has a login area that I could look at the coding for. I am trying to learn php and I learn best by looking off of a template. It can be an older php website doesn't matter. Thanks!
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    You can't look at PHP code/src as you can HTML.
    You'll need to download a script that someone has made, and have a look through that. try http://www.hotscripts.com/PHP/ or do a Google search.
     
  3. gmagnuson

    gmagnuson Guest

    Thanks that should help me!
     
  4. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Here's the code I use (you will need a database for the user info):

    This handles the login:
    PHP:
        function Validate(){
            global 
    $name;
            global 
    $password;
            global 
    $db;
            
    $users "SELECT * FROM users WHERE nick='$name'";
            
    $getval mysql($db,$users);
            if (
    mysql_numrows($getval) != 0){
                if (
    mysql_result($getval0'password') == $password){
                    return 
    true;
                }
                else return 
    false;
            }
            else return 
    false;
        }

        if(
    Validate()){
            
    session_start();
            
    session_register("pass_cookie");
            
    $pass_cookie $name;
            
    header("Location: logged_in.php");
        }
        else{
            
    // Authentication failed.
            
    header("Location: login.php?badpass=yes");
        }
    This is the first page:
    PHP:
    <FORM NAME="login" METHOD="post" ACTION="login_check.php" TARGET="main">
    Name: <INPUT TYPE="text" NAME="name"><BR>
    Password <INPUT TYPE="PASSWORD" NAME="password"><BR>
    <
    INPUT TYPE="Submit" VALUE="Log in" BORDER="0">
    </
    FORM>
     
  5. w0lv3rin3

    w0lv3rin3 The Source Political User

    Messages:
    465
    Location:
    Barrie, ON
    well if your new with php i suggest u get to know some of SQL ODBC DB

    PHP is a DB language, just pulls out info from those DB.