Frostbite Posted October 13, 2013 Share Posted October 13, 2013 Hello, I have been having trouble with this for quite some time I have tired to narrow it down the best I can. I able to complete the registration process, I went and check the sql database all fields have been filled. I think that the activation page cannot access the database to remove the active code. I tried to print or echo out the query value with echo "<p>Q: $q</p>" or print "<p>Q: $q</p>" all I see on the screen is "Q:" When I click the link from my email it doesn't seem to fail as it does not redirect me to index.php. I also do not get any error on my screen either. Any would help would be greatly appreciated. Regards Alex <div id="activate"> <?php /** * @author Alex Power * @copyright 2013 */ # Script 18.7 - activate.php require ('includes/config.inc.php'); $page_title='Activate Your Account'; if (isset($_GET['x'], $_GET['y']) && filter_var($trimmed['email'],FILTER_VALIDATE_EMAIL) && (STRlen($_GET['y']) == 32 )) { require (MYSQL); $q = "UPDATE users SET active=NULL WHERE (email='" . mysqli_real_escape_string($dbc, $_GET['x']) . "' AND active='" .mysqli_real_escape_sting($dbc, $_GET['y']) . "') LIMIT 1"; print "<p> Q: $q</p>"; $r = mysqli_query($dbc, $q) or trigger_error("Query:$q\n<br />)MySQL Error:" . mysqli_error($dbc)); if (mysqli_affected_rows($dbc)== 1 ) { echo "<h3>Your account is now active. You may now login.</h3>"; } else { echo '<p class="error">Your account could not be activated. Please re-check the link or contact the system administrator.</p>'; } mysqli_close($dbc); } else { //Redirect $url = BASE_URL . 'index.php'; ob_end_clean(); header("location:$url"); exit(); } // END of main IF-ELSE ?> </div> Link to comment Share on other sites More sharing options...
Larry Posted October 14, 2013 Share Posted October 14, 2013 Is your database set to allow NULL values for the active column? Link to comment Share on other sites More sharing options...
Frostbite Posted October 14, 2013 Author Share Posted October 14, 2013 I believe so yes. Below is a copy of my database. CREATE TABLE IF NOT EXISTS users( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_name VARCHAR(20) NOT NULL, email VARCHAR(60) NOT NULL, pass CHAR(40) NOT NULL, reg_date DATETIME NOT NULL, user_level TINYINT(1) UNSIGNED NOT NULL default 0, active CHAR(32), PRIMARY KEY (user_id), UNIQUE (user_name), UNIQUE (email), INDEX login (user_name, pass) )ENGINE = INNODB; Regards Alex Link to comment Share on other sites More sharing options...
Larry Posted October 15, 2013 Share Posted October 15, 2013 Okay, good. Could you provide an example URL that's being used to activate? Link to comment Share on other sites More sharing options...
Frostbite Posted October 15, 2013 Author Share Posted October 15, 2013 I hope this is what you meant: http://powerplaymc.co.uk/activate.php?x=eaxmple%40hotmail.com&y=83ffeabbc8e6701e16637e57075b2913 Regards Alex Link to comment Share on other sites More sharing options...
Larry Posted October 16, 2013 Share Posted October 16, 2013 Yes, that's what I meant. I wonder if the filter_var() is failing because of the %40 for @ in the email value. Try swapping that in the URL and see what happens. Link to comment Share on other sites More sharing options...
Frostbite Posted October 16, 2013 Author Share Posted October 16, 2013 I tired to change the %40 in the URL to @ but this did not work. it still just brings up a blank page with my main divs but no message saying it failed or succeed and does not redirect me to the index.php Regards Alex Link to comment Share on other sites More sharing options...
Larry Posted October 16, 2013 Share Posted October 16, 2013 Okay, I see what the problem is: $trimmed['email'] needs to be $_GET['x'] Link to comment Share on other sites More sharing options...
Frostbite Posted October 16, 2013 Author Share Posted October 16, 2013 Ok so I changed $trimmed['email'] to $_GET['x'] but that didn't work either, I still get a black screen with all my divs but no message if (isset($_GET['x'], $_GET['y']) && filter_var($_GET['x'],FILTER_VALIDATE_EMAIL) && (STRlen($_GET['y']) == 32 )) Maybe I laid it out wrong? Regards Alex Link to comment Share on other sites More sharing options...
Larry Posted October 16, 2013 Share Posted October 16, 2013 How about now changing the URL from %40 to @? Link to comment Share on other sites More sharing options...
Frostbite Posted October 17, 2013 Author Share Posted October 17, 2013 I tried to change that as well and still nothing. Regards Alex Link to comment Share on other sites More sharing options...
Larry Posted October 19, 2013 Share Posted October 19, 2013 Okay, do this at the top of the script and let us know what the results are: print_r($_GET); Link to comment Share on other sites More sharing options...
Frostbite Posted October 19, 2013 Author Share Posted October 19, 2013 Okay so I just put print_r($_GET); at the top of my code and this is what I got back. Array ( [x] => alexp2510@hotmail.com [y] => 254e24e81bdec9b1d4b7baaac3dc00d6 ) Regards Alex Link to comment Share on other sites More sharing options...
Frostbite Posted October 24, 2013 Author Share Posted October 24, 2013 Hi, Today I typed out the activation php code again. and what ever I did this time it seemed to work. Thank you for all your help. Link to comment Share on other sites More sharing options...
Recommended Posts