This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-11-04 15:33:35

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

MySQL Login Problem

I have no idea why this doesn't work, but it just doesn't!

Code:

$usern = mysql_real_escape_string($_POST['usern']);
$passw = hash('sha512', mysql_real_escape_string($_POST['passw']));
$query = "SELECT id FROM user_list WHERE usern='$usern' AND passw='$passw'";
$r = @mysql_query($query, $dbc);
if (mysql_num_rows($r)) {
    $_SESSION['loggedin'] = true;
    $_SESSION['usern'] = $usern;
}
if ($_SESSION['loggedin']) {
    header('Location: index.php');
    die;
} else {
    die('The entered username or password did not match those on file!');
}

Somebody please help!!!!!  yikes


Fork Clamor on GitHub!

Offline

 

#2 2011-11-04 15:40:55

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: MySQL Login Problem

What happens? what error message do you get?


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#3 2011-11-04 15:40:58

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

What error are you getting?

Edit: Pff 3 seconds after W.E.

Last edited by Magnie (2011-11-04 15:41:24)

Offline

 

#4 2011-11-04 15:42:03

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: MySQL Login Problem

Magnie wrote:

3 seconds after W.E.

lol ha  tongue


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#5 2011-11-04 15:49:21

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: MySQL Login Problem

I'm not getting any error message, I'm just getting the message that says that my username and password are incorrect, even though I know they are correct.


Fork Clamor on GitHub!

Offline

 

#6 2011-11-04 15:50:39

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

Well, for $r drop the ', $dbc' part and see what happens.

Offline

 

#7 2011-11-04 16:14:46

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: MySQL Login Problem

Magnie wrote:

Well, for $r drop the ', $dbc' part and see what happens.

Nope. That's not it.  hmm


Fork Clamor on GitHub!

Offline

 

#8 2011-11-04 16:50:05

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

Okay, echo the $usern, $passw, and mysql_num_rows($r)

Offline

 

#9 2011-11-04 16:54:59

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: MySQL Login Problem

I don't think you can use that header() function in the code.  hmm

Offline

 

#10 2011-11-04 16:55:03

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: MySQL Login Problem

I've got a problem too:

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<?php
session_start();
if ($_SESSION['loggedin']) {
include "demo.html";
include "connect.php";
$username = $_SESSION['username'];
if ($_POST['sendmessage']) {
$to = $_POST['to'];
$message = strip_tags($_POST['message']);
mysql_query("INSERT INTO messages (From:, Message:, reciever)
VALUES ('$username', '$message', '$to')");
header('Location: http://plaxon.comyr.com/index32.php');
}
} else {
header('Location: http://plaxon.comyr.com/error2.php');
}
?>

It never seems to run the MYSQL UPDATE code, with of without the , $con at the end  sad


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#11 2011-11-04 17:02:15

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: MySQL Login Problem

Magnie wrote:

Okay, echo the $usern, $passw, and mysql_num_rows($r)

The mysql_num_rows($r) echo said "0"


Fork Clamor on GitHub!

Offline

 

#12 2011-11-04 17:18:34

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

WindowsExplorer wrote:

I've got a problem too:

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<?php
session_start();
if ($_SESSION['loggedin']) {
include "demo.html";
include "connect.php";
$username = $_SESSION['username'];
if ($_POST['sendmessage']) {
$to = $_POST['to'];
$message = strip_tags($_POST['message']);
mysql_query("INSERT INTO messages (From:, Message:, reciever)
VALUES ('$username', '$message', '$to')");
header('Location: http://plaxon.comyr.com/index32.php');
}
} else {
header('Location: http://plaxon.comyr.com/error2.php');
}
?>

It never seems to run the MYSQL UPDATE code, with of without the , $con at the end  sad

Don't use colons for columns.

ohaiderstudios: Echo the $usern and make sure $passw has data in it.

Last edited by Magnie (2011-11-04 17:25:25)

Offline

 

#13 2011-11-04 17:22:51

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: MySQL Login Problem

Magnie wrote:

WindowsExplorer wrote:

I've got a problem too:

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<?php
session_start();
if ($_SESSION['loggedin']) {
include "demo.html";
include "connect.php";
$username = $_SESSION['username'];
if ($_POST['sendmessage']) {
$to = $_POST['to'];
$message = strip_tags($_POST['message']);
mysql_query("INSERT INTO messages (From:, Message:, reciever)
VALUES ('$username', '$message', '$to')");
header('Location: http://plaxon.comyr.com/index32.php');
}
} else {
header('Location: http://plaxon.comyr.com/error2.php');
}
?>

It never seems to run the MYSQL UPDATE code, with of without the , $con at the end  sad

Don't use colons for columns.

ProgrammingFreak: Echo the $usern and make sure $passw has data in it.

Me?

Offline

 

#14 2011-11-04 17:24:55

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

ProgrammingFreak wrote:

Magnie wrote:

WindowsExplorer wrote:

I've got a problem too:

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<?php
session_start();
if ($_SESSION['loggedin']) {
include "demo.html";
include "connect.php";
$username = $_SESSION['username'];
if ($_POST['sendmessage']) {
$to = $_POST['to'];
$message = strip_tags($_POST['message']);
mysql_query("INSERT INTO messages (From:, Message:, reciever)
VALUES ('$username', '$message', '$to')");
header('Location: http://plaxon.comyr.com/index32.php');
}
} else {
header('Location: http://plaxon.comyr.com/error2.php');
}
?>

It never seems to run the MYSQL UPDATE code, with of without the , $con at the end  sad

Don't use colons for columns.

ProgrammingFreak: Echo the $usern and make sure $passw has data in it.

Me?

Sorry meant ohaiderstudios  tongue

Offline

 

#15 2011-11-04 17:25:45

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: MySQL Login Problem

both $usern and $passw have values


Fork Clamor on GitHub!

Offline

 

#16 2011-11-04 17:27:05

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: MySQL Login Problem

Magnie wrote:

ProgrammingFreak wrote:

Magnie wrote:

Don't use colons for columns.

ProgrammingFreak: Echo the $usern and make sure $passw has data in it.

Me?

Sorry meant ohaiderstudios  tongue

Okay,  tongue

Offline

 

#17 2011-11-04 17:29:28

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

ohaiderstudios wrote:

both $usern and $passw have values

Have you opened the database ( with phpMyAdmin or something ) and checked the values manually ( with your eyes )?

Try changing SELECT id to SELECT *

Offline

 

#18 2011-11-04 17:42:47

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: MySQL Login Problem

I've figured it out! The SHA512 hash produced more characters than the database stored. The field was marked VARCHAR(50), but the hash produced a larger number of characters! Problem solved!


Fork Clamor on GitHub!

Offline

 

#19 2011-11-04 17:44:26

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

ohaiderstudios wrote:

I've figured it out! The SHA512 hash produced more characters than the database stored. The field was marked VARCHAR(50), but the hash produced a larger number of characters! Problem solved!

Cheers!

Offline

 

#20 2011-11-04 17:56:27

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: MySQL Login Problem

no one answered my question, so don't close this yet  sad  I still didn't get mine fixed


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#21 2011-11-04 18:18:33

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: MySQL Login Problem

WindowsExplorer wrote:

no one answered my question, so don't close this yet  sad  I still didn't get mine fixed

Actually, Magnie wrote:

Magnie wrote:

Don't use colons for columns.


Fork Clamor on GitHub!

Offline

 

#22 2011-11-04 18:33:23

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: MySQL Login Problem

ohaiderstudios wrote:

WindowsExplorer wrote:

no one answered my question, so don't close this yet  sad  I still didn't get mine fixed

Actually, Magnie wrote:

Magnie wrote:

Don't use colons for columns.

still not working  sad


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#23 2011-11-04 19:21:17

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

WindowsExplorer wrote:

ohaiderstudios wrote:

WindowsExplorer wrote:

no one answered my question, so don't close this yet  sad  I still didn't get mine fixed

Actually, Magnie wrote:

Magnie wrote:

Don't use colons for columns.

still not working  sad

Change the actual column and the code, when I look at your database it has "From:" and "Content:" also, make sure the first letter is lowercase.

Offline

 

#24 2011-11-05 03:37:19

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: MySQL Login Problem

Magnie wrote:

WindowsExplorer wrote:

ohaiderstudios wrote:

WindowsExplorer wrote:

no one answered my question, so don't close this yet  sad  I still didn't get mine fixed

Actually, Magnie wrote:

still not working  sad

Change the actual column and the code, when I look at your database it has "From:" and "Content:" also, make sure the first letter is lowercase.

stop looking at my database already!  mad


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#25 2011-11-05 08:41:03

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: MySQL Login Problem

WindowsExplorer wrote:

Magnie wrote:

WindowsExplorer wrote:


still not working  sad

Change the actual column and the code, when I look at your database it has "From:" and "Content:" also, make sure the first letter is lowercase.

stop looking at my database already!  mad

Okay, sorry, but did you get it working?

Offline

 

Board footer