Hi,
I am not sure what i am doing wrong.
I got my code (below) basically it is to resend user activation email if they for some reason or other did not get it first time etc.
It sends the email and everything etc... what i need to do it not only get the user email address which i can do no problem but to also fetch the user activation key and username from the DB.
Now if you look in my code i put
$query = ("SELECT * FROM userinformation WHERE `email` = '$email', `username` = ' ', `activationkey` = ' ' ");
the email part of it works as it checks the email address the user put in form against the DB but the activationkey and username part it does not get from DB.
I need to get the activation key from DB and username to as it needs to be stored in a variable like the email so it is sent along with the email.
Problem is like i said the activation key and username is not being fetched from DB.
Here is my code. I am very sure i am doing a very silly mistake again.
Thanks as always,
genieuk
<?php @include("/home/sites/mydomain.com/public_html/includes/top.inc"); ?>
<?php include("/home/sites/mydomain.com/public_html/includes/db_connect.php"); // Database Connection ?>
<?php
if (isset($_POST['submitted'])) { // Handle the form.
$email = htmlspecialchars( strtolower( stripslashes( strip_tags($_POST['email'] ) ) ) );
if ( empty($_POST['email'] ) ) {
echo "<p><span class=\"error\">You must enter the email address you signed up with in order to request your activation email to be resent</span></p>";
$err++;
}
if (!filter_var( $_POST['email'] , FILTER_VALIDATE_EMAIL)) {
$err++;
echo "<p><span class=\"error\">Your email address is not a valid format</span></p>";
$err++;
}
$emailcheck = mysql_query("SELECT * FROM userinformation WHERE `email` = '$email'");
if( @mysql_num_rows( $emailcheck ) == false ) {
echo "<p><span class=\"error\">The email address you supplied is not associated with an account.</span></p>";
$err++;
}
$statuscheck = mysql_query("SELECT * FROM userinformation WHERE `email` = '$email' AND `status` = 'activated' ");
if( @mysql_num_rows( $statuscheck ) == true ) {
echo "<p><span class=\"error\">The email address you supplied has already been activated with an account.</span></p>";
$err++;
}
if ($err == 0) {
$query = ("SELECT * FROM userinformation WHERE `email` = '$email', `username` = '', `activationkey` = ''");
$result = mysql_query($query);
if ($result == true) {
while($row = mysql_fetch_array($result)) {
$to = $row[email];
$username = $row[username];
$activationkey = $row[activationkey];
// Details to be sent with email
$subject = "Account Activation & Login Details";
$headers = "From: no-reply@mydomain.com";
$headers .= "content-type: text/html \r\n";
$message .= '<p><font face=\"Verdana\" color=\"#000000\">Thank you '.$username.' for registering with us at Mathew\'s Website</font></p>';
$message .= "<p><font face=\"Verdana\" style=\"font-size: 11pt\">Below is your Username and Password you signed up with.";
$message .= "<p><font face=\"Verdana\" style=\"font-size: 11pt\">Please keep these safe in case you forget them</font></p>";
$message .= '<p><font face="Verdana" style="font-size: 11pt">Username: <b>'.$username.'</b></font></p>';
$message .= '<p><font face="Verdana" style="font-size: 11pt">Password: <b>'.$password.'</b></font></p>';
$message .= "<p><b><font face=\"Verdana\" style=\"font-size: 11pt\" color=\"#FF0000\">In order to use your account you must first activate your account.";
$message .= "<p><font face=\"Verdana\" style=\"font-size: 11pt\">Below is your unique link to activate your account.</font></p>";
$message .= "<p><font face=\"Verdana\" style=\"font-size: 11pt\">Please click on the link to activate your account.</font></p>";
$message .= "<p><font face=\"Verdana\" style=\"font-size: 11pt\"><a href=\"http://www.mydomain.com/signup/verify.php?key=$activationkey\">Click Me to Activate Your Account</a></font></p>";
$message .= '<font face="Verdana" style="font-size: 11pt">Thanks, as always</font></p>';
$message .= "<font face=\"Verdana\" style=\"font-size: 11pt\">Mathew</font></p><br /><br />";
$message .= "<font color=\"#000000\" size=\"2\" face=\"Verdana, Geneva, sans-serif\"><div style=\"text-align: center;\"><p>If you feel you received this email in error please ignore this email.</p></div></font>";
// Mail the user
mail( $to, $subject, $message, $headers );
}
}
else {
echo "<span class=\"error\"><p>Sorry we was unable to process your request at this time. Please try again later.</p></span>";
}
}
}
?>
<h4>Resend Activation Email</h4>
<p>If you have not received your activation email, request it to be resent here.</p>
<p>It may sometimes take up to 15 minutes before you receive your activation email.</p>
<p>Remember to also check your spam folder.</p>
<p>If you still do not receive your activation email after 60 minutes and after requesting</p>
<p>it to be resent, please contact us using our <a href="http://www.genieuk.co.cc/contact/contactus.php" title="Having problems? , not receiving your activation email? , please contact us so we can help sort the problem.">contact form</a> so we can help to sort the problem.</p>
<form action="resendactivationemail.php" method="post">
<b>Please enter the email address you signed up with</b> <br />
<input type="text" name="email" maxlength="50" size="20" />
<br /> <br />
<input type="submit" name="submit" value="Resend Activation Email" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
<?php @include("/home/sites/mydomain/public_html/includes/footer.inc"); ?>