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