Results 1 to 3 of 3

Thread: [PHP] Help

  1. #1
    Join Date
    Feb 2007
    Location
    West Midlands
    Posts
    1,168
    Tokens
    0
    Habbo
    Jibbish

    Latest Awards:

    Default [PHP] Help

    Ok, i'm using a usersystem of techtuts but edited it. But the problem is when I fill all the crap to login the form won't submit.

    I've registered, and done all the SQL tables
    heres the code

    PHP Code:
    <?php
    session_start
    ();
    include (
    'includes/config.php');
    if (!
    $user['username']){ //If the user isnt logged in
    if (!$_POST['login']){ //If the form hasn't been submit        
    if ($_SESSION['three'] =="on"){ //If session 3
    $read "readonly"//Set the html to stop people typing in the boxes        
    }        
    else
    {
    $read ""//Allows people to type in the box
    }
    echo(
    "                         
                                                <form method=\"post\">
                                              <strong>Username:</strong><br />
                                              <input name=\"username\" type=\"text\" value=\"Username...\" /><br />
                                              <strong>Password:</strong><br />
                                              <input name=\"pass\" type=\"password\" value=\"password\" /><br />
                                              <br />
                                              <input name=\"login\" type=\"button\" value=\"Login\" />                                    
                                              </form>
    "
    );
                                              }
    if (
    $_SESSION['three'] == "on"){ //If session two is on
                    
                    
    print "<a href=\"main.php?page=content/fp.php\"><center><strong>I've forgotten my password</strong><center></a>"//Give them the link to recover their password
                    
    unset($_SESSION['two']); //Unsets the second session
                    
            
    }
            
            if (
    $_SESSION['two'] == "on"){ //If session two is on
                    
                    
    print "<center><strong>You have 1 chance left!</strong></center>"//Tell them they have 1 chance left to login
                    
    unset($_SESSION['one']); //Unsets the second session
                    
            
    }
                
            if (
    $_SESSION['one'] == "on"){ //If session one is on
                    
                    
    print "<center><strong>You have 2 chances left!</strong></center>"//Tell them the gave 2 chances left to login
                    
            
    }
        
        }
        
        elseif (
    $_POST['login']){ //If the form has been submit
        
            
    $username mysql_real_escape_string($_POST['username']); //Post the username box
            
    $password md5($_POST['pass']); //Post the password box    
            
    $check mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); //Querries the database for the submit username
            
    $find mysql_num_rows($check); //Adds up how many times the username is in the database
            
    while ($c mysql_fetch_array($check)){ //Fetches the array for that row
                
                
    if ($password != $c['password'] || $find == "0"){ //If the password dones't match the registered one or the username isnt registered
                
                    
    print "Incorrect username or password!"//Show and error
                    
                    
    if ($_SESSION['two'] == "on"){ //If session two is on
                    
                    
    session_cache_limiter('private');
                    
    $cache_limiter session_cache_limiter();
                    
                    
    /* set the cache expire to 30 minutes */
                    
    session_cache_expire(30);
                    
    $cache_expire session_cache_expire();
                    
                    unset(
    $_SESSION['two']); //Unsets the second session
                    
    session_start(); //Starts the session
                    
    $_SESSION['three'] = "on"//Sets the session named three to on
                    
                    
    }
                
                    if (
    $_SESSION['one'] == "on"){ //If session one is on
                    
                    
    unset($_SESSION['one']); //Unsets the first session
                    
    session_start(); //Starts the session
                    
    $_SESSION['two'] = "on"//Sets the session named two to on
                    
                    
    }
                    
                    if (
    $_SESSION['one'] != "on" || $_SESSION['two'] != "on" || $_SESSION['three'] != "on"){ //If none of the sessions are set
                    
                    
    session_start(); //Starts the session
                    
    $_SESSION['one'] = "on"//Sets the session named one to on
                    
                    
    }
                
                }
                
                elseif (
    $password == $c['password']){ //If the password does match the registered one and the username is registered
                
                    
    session_start();
                    
                    
    $_SESSION['username'] = $username//Starts the session with the users username        
                    
    $_SESSION['password'] = $password//Starts the session with the users password
                    
                    
    print "<center>You are logged in and will be redirected in 3 seconds!<br /><img src=\"ajax-loader.gif\" width=\"16\" height=\"16\" alt=\"Loading\" /></center>";
                    
                    
    $page $_SERVER["HTTP_REFERER"]; //The page the user came from
                    
                    
    print "<meta http-equiv=\"Refresh\" content=\"3;url=$page\">"//Sends the user to the specified page
                    
                
                
    }
            
            }
        }
        if (
    $user['username']){ //If the user is logged in
        
    print "
                                            » Inbox<br />
                                            » Send Message<br />
                                            » Your Account<br />
                                            » Logout
        "
    //Gives the user a list of what they can now do

    }
    ?>

  2. #2
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    You didnt say where you wanted it to submit to.

    PHP Code:
    <?php
    session_start
    ();
    include (
    'includes/config.php');
    if (!
    $user['username']){ //If the user isnt logged in
    if (!$_POST['login']){ //If the form hasn't been submit        
    if ($_SESSION['three'] =="on"){ //If session 3
    $read "readonly"//Set the html to stop people typing in the boxes        
    }        
    else
    {
    $read ""//Allows people to type in the box
    }
    echo(
    "                         
                                               <form method=\"post\" action=<? 
    $_SERVER['PHP_SELF']; ?>>

                                              <strong>Username:</strong><br />
                                              <input name=\"username\" type=\"text\" value=\"Username...\" /><br />
                                              <strong>Password:</strong><br />
                                              <input name=\"pass\" type=\"password\" value=\"password\" /><br />
                                              <br />
                                              <input name=\"login\" type=\"button\" value=\"Login\" />                                    
                                              </form>
    "
    );
                                              }
    if (
    $_SESSION['three'] == "on"){ //If session two is on
                    
                    
    print "<a href=\"main.php?page=content/fp.php\"><center><strong>I've forgotten my password</strong><center></a>"//Give them the link to recover their password
                    
    unset($_SESSION['two']); //Unsets the second session
                    
            
    }
            
            if (
    $_SESSION['two'] == "on"){ //If session two is on
                    
                    
    print "<center><strong>You have 1 chance left!</strong></center>"//Tell them they have 1 chance left to login
                    
    unset($_SESSION['one']); //Unsets the second session
                    
            
    }
                
            if (
    $_SESSION['one'] == "on"){ //If session one is on
                    
                    
    print "<center><strong>You have 2 chances left!</strong></center>"//Tell them the gave 2 chances left to login
                    
            
    }
        
        }
        
        elseif (
    $_POST['login']){ //If the form has been submit
        
            
    $username mysql_real_escape_string($_POST['username']); //Post the username box
            
    $password md5($_POST['pass']); //Post the password box    
            
    $check mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); //Querries the database for the submit username
            
    $find mysql_num_rows($check); //Adds up how many times the username is in the database
            
    while ($c mysql_fetch_array($check)){ //Fetches the array for that row
                
                
    if ($password != $c['password'] || $find == "0"){ //If the password dones't match the registered one or the username isnt registered
                
                    
    print "Incorrect username or password!"//Show and error
                    
                    
    if ($_SESSION['two'] == "on"){ //If session two is on
                    
                    
    session_cache_limiter('private');
                    
    $cache_limiter session_cache_limiter();
                    
                    
    /* set the cache expire to 30 minutes */
                    
    session_cache_expire(30);
                    
    $cache_expire session_cache_expire();
                    
                    unset(
    $_SESSION['two']); //Unsets the second session
                    
    session_start(); //Starts the session
                    
    $_SESSION['three'] = "on"//Sets the session named three to on
                    
                    
    }
                
                    if (
    $_SESSION['one'] == "on"){ //If session one is on
                    
                    
    unset($_SESSION['one']); //Unsets the first session
                    
    session_start(); //Starts the session
                    
    $_SESSION['two'] = "on"//Sets the session named two to on
                    
                    
    }
                    
                    if (
    $_SESSION['one'] != "on" || $_SESSION['two'] != "on" || $_SESSION['three'] != "on"){ //If none of the sessions are set
                    
                    
    session_start(); //Starts the session
                    
    $_SESSION['one'] = "on"//Sets the session named one to on
                    
                    
    }
                
                }
                
                elseif (
    $password == $c['password']){ //If the password does match the registered one and the username is registered
                
                    
    session_start();
                    
                    
    $_SESSION['username'] = $username//Starts the session with the users username        
                    
    $_SESSION['password'] = $password//Starts the session with the users password
                    
                    
    print "<center>You are logged in and will be redirected in 3 seconds!<br /><img src=\"ajax-loader.gif\" width=\"16\" height=\"16\" alt=\"Loading\" /></center>";
                    
                    
    $page $_SERVER["HTTP_REFERER"]; //The page the user came from
                    
                    
    print "<meta http-equiv=\"Refresh\" content=\"3;url=$page\">"//Sends the user to the specified page
                    
                
                
    }
            
            }
        }
        if (
    $user['username']){ //If the user is logged in
        
    print "
                                            » Inbox<br />
                                            » Send Message<br />
                                            » Your Account<br />
                                            » Logout
        "
    //Gives the user a list of what they can now do

    }
    ?>
    Lets set the stage on fire, and hollywood will be jealous.

  3. #3
    Join Date
    Feb 2007
    Location
    West Midlands
    Posts
    1,168
    Tokens
    0
    Habbo
    Jibbish

    Latest Awards:

    Default

    It still doesn't do anything, and wouldn't that code accept any login with the correct password or w.e?

Posting Permissions

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