Jump to content

Login Problems


wickedXxxxlegox

Recommended Posts

'Ello everyone.

 

 

I am having a problem with my login system. When I try to log in, it says login failed even though I have the correct username and pass. My username is Andrew Baker, and my pass is obviously a secret. Here's the code to checklogin.php:

<?php
// checkLogin.php
require('includes/header.php'); 
session_start(); // Start a new session
require('includes/db_connect.php'); // Holds all of our database connection information


// Get the data passed from the form
$username = $_POST['user'];
$password = $_POST['password'];


// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);


$sql = "select * from members where username = '$username' and password = '$password'";
$result = mysql_query($sql) or die ( mysql_error() );


$count = 0;


while ($line = mysql_fetch_assoc($result)) {
    $count++;
}


if ($count == 1) {
    $_SESSION['loggedIn'] = "true";
    header("Location: home.php"); // This is wherever you want to redirect the user to
} else {
    $_SESSION['loggedIn'] = "false";
    header("Location: loginfailed.php"); // Wherever you want the user to go when they fail the login
}


?>


 

Thanks! ;):rtfm:

 

If you need any more info then reply down here vvvvv

Link to comment
Share on other sites

How can you possibly say there's no error when you are the one who posted the error to begin with? Here, let me quote it for you, from your very own post:

 

Well, now I have a problem with my code that is echoing it.

[sNIP]

Error: Parse error: syntax error, unexpected '[' in /home/a1922355/public_html/dbtest.php on line 6

 

Oh, and trying to get you to read and understand your own code isn't "treating people like crap", it's trying to help you learn how to debug your own code, so you don't need to post every little syntax error you encounter.

Link to comment
Share on other sites

He isn't treating you like crap, he was just trying to get you to find you're own error, him telling you the exact problem isn't going to solve anything, you'll end up posting the same question next time.

 

look at the error close,  Error: Parse error: syntax error, unexpected '[' in /home/a1922355/public_html/dbtest.php on line 6

 

now, look at you're code.

 

<?php

include('includes/db_connect.php');

mysql_query('SELECT * FROM members');

echo ("".srow['username'[]);

?>

 

basically, you're closing ['username'] like ['username'[ which is causing errors for you.  :P

Link to comment
Share on other sites

There isn't an error. Stop treating people like crap. It makes me want to leave this site.

 

LOL..... these guys are helping you voluntarily...

 

sit back and take there advice with NO grain of salt, that is the only way to succeed, trust me, I know.

 

sit back and enjoy the ride, trust me, they know what they're talking about :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.