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
    New Coder
    Join Date
    Jul 2002
    Location
    UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with login script

    hi there.

    below is a simple register.php script that registers user name and password in a table.

    but i dont know how to create a login script, can someone help.

    (if login successful to go to welcome.php)

    PHP Code:
    <?php 
    function showheader ($title) { 
    ?> 
    <HTML> 
    <HEAD> 
    <TITLE><?php echo $title ?></TITLE> 
    </HEAD> 
    <BODY> 
    <CENTER> 
    <?php 


    function 
    showfooter () { 
    ?> 
    </CENTER> 
    </BODY> 
    </HTML> 
    <?php 


    mysql_connect("localhost""scpacouk""w761730e"); 
    mysql_select_db("scpacouk"); 

    if (
    $Password == $Password2) { 
        
    $user mysql_query("SELECT * FROM users WHERE (Name='$Name')"); 
        if (
    mysql_num_rows($user) > 0) { 
            
    showheader("User Name Taken !"); 
            
    ?> 
            User Name <B><?php echo $Name ?></B> Is already Taken. 
            <?php 
            showfooter
    (); 
        } 
        else { 
            
    $user mysql_query("INSERT INTO users VALUES ('$Name','$Password')"); 
            
    setcookie("site_user"$Nametime() + 31536000"/"); 
            
    setcookie("site_pass"$Passwordtime() + 31536000"/"); 
            
    showheader("Registration Success!"); 
            
    ?> 
            You have registered.<BR> 
            User Name: <?php echo $Name ?> 
            <BR> 
            Password: <?php echo $Password ?> 
            <?php 
            showfooter
    (); 
        } 

    else { 
        
    showheader("Registration Error!"); 
        
    ?> 
        Your Two Passwords Did Not Match 
        <?php 
        showfooter
    (); 

    ?>
    Last edited by andrewsheldon98; 02-07-2003 at 05:59 PM.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You will want to get into using sessions as well once they have logged in.

    http://www.webmasterbase.com/article/319

    http://hotwired.lycos.com/webmonkey/...tw=programming
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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