Jump to content
Larry Ullman's Book Forums

Having Problems With Chapter 18 Email Activation


Recommended Posts

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

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

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

 Share

×
×
  • Create New...