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 3 of 3

Thread: Why? :(

  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post

    Why? :(

    For some reason the check_login.php page is just displayed blank, so it is running the script but ending somewhere it isnt ment to :/

    Help please?

    PHP Code:
    <?php
    session_start
    ();

    include 
    "connect.php";

    //Checks for error in connecting to database
    if (!$con) {
        
    $mess "Error connecting to database! Error: ".mysql_error(); // Error connection to mysql database
        
    header("Location:../login.php?mess=$mess");
    }

    $uname$_POST['username'];
    $pwordmd5($_POST['password']);
    $remMe$_POST['rememberme'];

    if (
    $uname == "" || $pword == "") { 
        
    $mess "Invalid username or password!"// No username has been entered
        
    header("Location:../login.php?mess=$mess");

        elseif (isset(
    $_SESSION['username']) && isset($_SESSION['password'])) {
                
    $mess "You are already logged in!";
                
    header("Location:../index.php?mess=$mess");
        }    else    {
            
    //Tests have been passed
            
    mysql_select_db($dbname$con);
            
    $query=mysql_query("SELECT * FROM users");
                if (!
    $query) { 
                    
    $mess "Unable to login! (Technical error)";
                    
    header("Location:../login.php?mess=$mess");
                }
            
            
    //Check if username and password matchs
            
    while ($row=mysql_fetch_array($query)) {
                
    $username=$row['username'];
                
    $password=$row['password'];
                
                if (
    $uname == $username && $pword == $password) {
                
    // Username and password matches, make session variables
                    
    $_SESSION['username']=$uname;
                    
    $_SESSION['password']=md5($pword);
                    
                    
    //Check is remember password has been set
                    
    if ($remMe==1) {
                        
    //Create cookies
                        
    setcookie("user""$uname".md5($pword), time()+0*0*0*7);
                    }
                    
    //Now redirect to main page
                    
    echo "Woop!";
                    
    $mess "Login successfull!";
                    
    header("Location:../index.php?mess=$mess");
                }
            } 
    //END While
        
    }
    ?>
    +Does the script look good?
    Last edited by martynball; 03-24-2010 at 01:08 AM.

  • #2
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Changed question.

  • #3
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Start with #2 from the forum guidelines:
    2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post. Examples of poor subject titles include:

    - "Help!"
    - "I'm a newbie...be gentle"
    - "How can I..."
    - "Urgent...deadline tomorrow!"

    The above subjects either have absolutely nothing to do with the question itself, or are grossly incomplete (ie: "How can I..."). When asking for help, enter a subject that summarizes your question, period! Don't use silly, incomplete, or "bait" subjects. Some examples of good titles are:

    - "How do I round a number to 2 decimal places using JavaScript?"
    - "What's the difference between require() and include() in PHP?"
    - "Can someone suggest a good, free HTML editor?"
    Then, note that a blank page usually indicates a syntax error or parse error and that your error reporting is turned off. A forum search will show you how to turn it on so you can get the error. With all of those header() functions, I'll bet it's going to be complaining about "headers already sent".
    Are you a Help Vampire?


  •  

    Posting Permissions

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