Jump to content
Larry Ullman's Book Forums

adriandaniel

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

1 Neutral

About adriandaniel

  • Rank
    Newbie
  1. Hi Antonio, Thank you for taking your time to help me. I really appreciate it. I finally found the issue. Which is a bit stupid. It was just the activation link in the registration.php page it was missing the 'x=' before the actual get user id query All the best
  2. Hi Antonio, My apologies, I didn't think of putting code. I believe the problem is that in the link sent by email it looks like this http://uel-kbs.co.uk/activate.php12&y=3c6e0ec639a3d4b9127ca4e68fbafe50 So the browser is actually looking for the file activate.php including rest of variables. Which is why it cannot find it on the server as the file is just activate.php I know the rest of the variables in that file name represent the user id and status active ( x, y) but how would it know that it actually has to go to the activate.php page? Here is the part of the code from the activate.php page that represents defining the URL. Maybe this is the problem. // If $x and $y aren't correct, redirect the user. if ( ($x > 0) && (strlen($y) == 32)) { require_once ('./mysql_connect.php'); // Connect to the database. $query = "UPDATE users SET active=NULL WHERE (user_id=$x AND active='" . escape_data($y) . "') LIMIT 1"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); // Print a customized message. if (mysql_affected_rows() == 1) { echo "<h3>Your account is now active. You may now log in.</h3>"; } else { echo '<p><font color="red" size="+1">Your account could not be activated. Please re-check the link or contact the system administrator.</font></p>'; } mysql_close(); } else { // Redirect. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. And the following thread of coding is from the register page, which generates the email: // Make sure the email address is available. $query = "SELECT user_id FROM users WHERE email='$e'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_num_rows($result) == 0) { // Available. // Create the activation code. $a = md5(uniqid(rand(), true)); // Add the user. $query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln', '$a', NOW() )"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_affected_rows() == 1) { // If it ran OK. // Send the email. $body = "Thank you for registering at the User Registration site. To activate your account, please click on this link:\n\n"; $body .= "http://uel-kbs.co.uk/activate.php" . mysql_insert_id() . "&y=$a"; mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@uel-kbs.co.uk'); // Finish the page. echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; include ('./includes/footer.html'); // Include the HTML footer. exit(); Hope this clarifies a bit the problem. Many thanks, Adrian
  3. Hi Guys, I have been using Larry's book recently and I must say it is amazing how straight forward it is and how much is helping me learn PHP and MYSQL. My question is from chapter 13. I managed to make everything work beside the activate.php page which I send to the user via email so they can activate their account. When they click on the link from the email the browser doesn't find the page although it is in the same folder on the server as the other files. What can be the cause of that? Kind Regards, Adrian
×
×
  • Create New...