Jump to content
Larry Ullman's Book Forums

uncfelt1147

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by uncfelt1147

  1. I can't seem to get my activation link (code) to properly activate the link. I had a lot of trouble debugging it, but once I finished with that, the code runs through, and it keeps saying, "Your account could not be activated. Please re-check the link or contact the administrator." I can't tell what is failing though? Does my code look alright? I am almost sure that my database is correct.

     

    Here is the main body of my code:

     

     

    <?php
    
    if (isset($_GET['x'], $_GET['y']) && filter_var($_GET['x'], FILTER_VALIDATE_EMAIL) && (strlen($_GET['y']) == 32 )) {
    
    require (MYSQL);
    $q = "UPDATE users SET active=NULL WHERE email=' " . mysqli_real_escape_string($dbc, $_GET['x']) . "' \n"
    . "\n"
    . "AND \n"
    . " \n"
    . "active=' " . mysqli_real_escape_string($dbc, $_GET['y']) . "' \n"
    . "\n"
    . "LIMIT 1";
    
    $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; log in at any time.</h3>";
    
    } else {
    echo '<p class="error">Your account could not be activated. Please re-check the link or 
    contact the administrator.</p>';
    }
    
    mysqli_close($dbc);
    
    } else {
    
    $url = BASE_URL . '/index.php';
    ob_end_clean();
    header("Location: $url");
    exit();
    }
    
    ?>

     

    I know that my query is written very oddly. I wrote it like that because it kept feeding me errors and I just wanted it to work for now, so I fed it in very discretely.

     

    Any help would be greatly appreciated.

×
×
  • Create New...