Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-23-2010, 11:37 PM   PM User | #1
martynball
Regular Coder

 
Join Date: Nov 2007
Posts: 554
Thanks: 231
Thanked 0 Times in 0 Posts
martynball is an unknown quantity at this point
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 12:08 AM..
martynball is offline   Reply With Quote
Old 03-24-2010, 12:12 AM   PM User | #2
martynball
Regular Coder

 
Join Date: Nov 2007
Posts: 554
Thanks: 231
Thanked 0 Times in 0 Posts
martynball is an unknown quantity at this point
Changed question.
martynball is offline   Reply With Quote
Old 03-24-2010, 01:47 AM   PM User | #3
tomws
Senior Coder

 
tomws's Avatar
 
Join Date: Nov 2007
Location: Arkansas
Posts: 2,644
Thanks: 29
Thanked 330 Times in 326 Posts
tomws will become famous soon enoughtomws will become famous soon enough
Start with #2 from the forum guidelines:
Quote:
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?
tomws is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:40 PM.


Advertisement
Log in to turn off these ads.