very new to PHP and working on a mailing list with double opt-in. I found this code here: http://www.sitepoint.com/forums/showthread.php?632689-Guide-to-creating-a-double-opt-in-email-list&s=560d4d5d106fde7ccc1a53b507c436cd&p=4350152&viewfull=1#post4350152 and made it work until I click on the link in the e-mail, for some reason it doesn't update the status in the database to "confirmed" (it says "Sorry, account unvalidated").
I can't find the error with my basic knowledge, would appreciate some help! Thanks a lot JD
signup.php:
<?php
if(true === array_key_exists('submit', $_POST))
{
require("connect.php");
$rResult = mysqli_query($conn,
    sprintf(
        "INSERT INTO newsletter2 (email, status)VALUES('%s', 'pending')",
        $_POST['email']
    )
);
mail(
    $_POST['email'],
    'Subscriber Confirmation',
    sprintf(
        'Thankyou, please visit http://****.com/newsletter2/confirmSignUp.php?key=%s to confirm your subscription.',
        sha1($_POST['email'])
    ),
    null,
    null
);
echo 'Thankyou, please check the provided email for a link to confirm your subscription.';
exit;
}
?>
confirmSignUp.php:
<?php
if(true === array_key_exists('key', $_GET))
{
require("connect.php");
$rResult = mysqli_query($conn,
    sprintf(
        "UPDATE newsletter2 SET status = 'confirmed' WHERE email = SHA1('%s')",
        $_GET['key']
    )
);
if(mysqli_affected_rows($conn) > 0)
{
    echo 'Thankyou, email confirmed';
}
else
{
    echo 'Sorry, account unvalidated.';
}
exit;
}
?>
 
    