Jump to content

[SOLVED] A silly Mistake?


Accurax

Recommended Posts

Ive been staring at this for the last hour and i cant see where the mistake is.... ive had it working before.

This morning i added the if statement, as i wanted to get new members to type there password twice.

It all seems to work, except that it wont actually enter the info into the database, it just drops to the or die statment, can anyone see what ive done worng please?

[code]
<?php
include("info.inc");

$connection=mysql_connect($host, $user, $passwd)
or die ("Could not connect !");
$db = mysql_select_db($database, $connection)
or die ("Could not connect to Database");

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$usermail = $_POST['usermail'];

if ( $password == $password2)
{
$pass = md5($password);
$key = md5($user_name);

$query = "INSERT INTO members (user_name, email, password, key)
VALUES ('$username', '$usermail', '$pass', '$key')";
$result = mysql_query($query)
or die ("could not add user.");
}
else
{
header("location: passnomatch.php");
}

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/32828-solved-a-silly-mistake/
Share on other sites

OK.

Can't see the form so make sure that has the correct fields.

when comparing strings try using strcmp($password, $password2) == 0 (I think thats just good practice!)

BUT the one thing that kills it is $key=md5($user_name);

you have no $user_name - just $username so I suspect the key field in your database is not null and has no default value it will always get the md5 of null.

PS Just read thorpes - key is indeed a reserved word!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.