Jump to content
Larry Ullman's Book Forums

Recommended Posts

I've used the logging in and Logging Out scripts (Chapter 16: Example—User Registration) on my local server and everything worked fine though without activation. Now, I've uploaded the files to a remote server and off course using the activation script.

 

The activation works fine but I can't log in.I defined the 'active' column in the database as NULL. So after activation, I see 'NULL' replace the activation code yet can't log in. what's cooking?

Link to comment
Share on other sites

Could you please give us some more details?

 

Perhaps post some relevant code segments, or if there are any messages being output to the screen, what are those? Also, try echoing things to the screen, to see if you can diagnose the problem yourself.

  • Upvote 1
Link to comment
Share on other sites

Following is my Web host phpMyAdmin detail:

 

MySQL Server: Localhost via UNIX socket

Server version: 5.0.92-community

Protocol version: 10

User: smarttis@localhost

MySQL charset: UTF-8 Unicode (utf8)

Web server

cpsrvd 11.28.87

MySQL client version: 4.1.22

PHP extension: mysql

phpMyAdmin

Version information: 3.3.9.2

 

Following is my part of my registration code:

 

if($fn && $ln && $em && $city && $cty && $ph && $abda && $abmo && $abye && $p && $tq && $ta)

{

 

$q = "SELECT email FROM register WHERE email='$em'";

 

$r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: ".mysqli_error($dbc));

 

if(mysqli_num_rows($r) == 0)

{

 

$a = md5(uniqid(rand(), true));

$pass=md5('$p');

 

$q = "INSERT INTO register(first_name, last_name, middle_name, address, email, phone, sex, city, country, active, dob_day, dob_month, dob_year, pass, question, answer, date_registered) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())";

 

$stmt = mysqli_prepare($dbc, $q);

mysqli_stmt_bind_param($stmt, 'ssssssssssisisss', $fn, $ln, $mn, $ad, $em, $ph, $sex, $city, $cty, $a, $abda, $abmo, $abye, $pass, $tq, $ta);

mysqli_stmt_execute($stmt);

 

if(mysqli_stmt_affected_rows($stmt)==1)

{

 

 

Following is my part of my login code

 

if($e && $p)

{

 

$q = "SELECT user_id, first_name, user_level FROM register WHERE (email = '$e' AND pass=md5('$p')) AND active IS NULL";

 

$r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error:".mysqli_error($dbc));

 

if(@mysqli_num_rows($r) == 1)

{

 

Note: I used SHA1() for encryption before changing to MD5() as the problem persisted

Link to comment
Share on other sites

I've never used prepared statements before, so not 100% sure about that syntax, but I do not get the 'ssssssssssisisss' string. Also, I think you need to insert NULL for an ID value, assuming you have an auto-incrementing ID in the table.

 

We can't see your database (and you don't need to show us), but I am wondering whether the users are even being registered in the database. Check out the content of the database, and make sure that the users are being registered properly in the first place.

 

Please let us know what the situation is.

Link to comment
Share on other sites

HartleySan, that string is part of how one does prepared statements.

 

Awkuzu, what is your pass column defined as? Also, do you have a user_level column in your table? You don't mention it in the INSERT query.

Link to comment
Share on other sites

 Share

×
×
  • Create New...