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"); ?>

I think this is about the third post like this, you aren't actually querying. You have to call mysql_query, right now you just have it wrapped in parenthesis.

I think this is about the third post like this, you aren't actually querying. You have to call mysql_query, right now you just have it wrapped in parenthesis.

Hi,

You have lost me, what you mean i am not querying? i am querying as it gets the email from the db but not the username and activation key. if it was not querying it would not get the email from DB. Because i done:

$query = ("SELECT * FROM userinformation WHERE `email` = '$email', `username` = '', `activationkey` = ''");
$result = mysql_query($query);

MySQL is confusing me allot. I don't get what you mean

thank you,
genieuk

No, you're not querying.

$query = ("SELECT * FROM userinformation WHERE `email` = '$email', `username` = ' ', `activationkey` = ' ' ");

should be

$query = mysql_query("SELECT * FROM userinformation WHERE `email` = '$email', `username` = ' ', `activationkey` = ' ' ");

No, you're not querying.

$query = ("SELECT * FROM userinformation WHERE `email` = '$email', `username` = ' ', `activationkey` = ' ' ");

should be

$query = mysql_query("SELECT * FROM userinformation WHERE `email` = '$email', `username` = ' ', `activationkey` = ' ' ");

yes but this is why i got

$result = mysql_query($query);

underneath it. Surely that means the same thing?, i am querying the variable $query using the above code.

Unless it does not.

thank you,
genieuk

Ahh, I didn't see that. Why do you have parenthesis around it, and why are you mixing saving the query to a variable then querying versus just querying?

AND is used instead of commas in the WHERE clause.

SELECT * FROM userinformation WHERE `email` = '$email' AND `username` = '' AND `activationkey` = ''

Thank you,

Much appreicated. Will try it now.

Sorry to confuse, that is the way i learnt it from a book i got, strangely enough it sounds the wrong way to do it, making more work for myself.

Will post back to let you know if it works.

Thank you,
genieuk

Hi,

for some reason it won't even send the email now using the above.

when it fetches data from DB and obviouly i dont know what the activation key is going to be is it correct to use like below? i mean where it has the commas after the = for activation key for example does that mean if nothing is between the ' ' it will get the data from DB? as this is what i need for it to do is get the activation key and username from DB, the email part worked fine on my last one as it simply just checked the email from the form with email in DB.

$query = ("SELECT * FROM userinformation WHERE `email` = '$email' AND `username` = '' AND `activationkey` = ''");
	$result = mysql_query($query);

thank you,
genieuk

Well if you want the activation key to be equal to something then put the variable in there like you did with $email

Hi,

thing is it not equal to anything.

The activation key is in the Data Base under the actiationkey field.

something like:

activationkey (field)
465346436544256575454768653978354754765437650

now i need to get that key from the DB and store as a variable like the email, same goes for username.

Problem is it is not getting the activation key and persons username from the DB.

I need it to get the activation key and username so it can be stored in a variable and used in the email. without the activationkey code like shown above the user cannot activate there account as the activationkey is added to the email like:

http://www.mydomain.com/signup/verify?=key$activationkey

thank you,
genieuk

Go read up on how SQL works then come and ask the question again, I'm not going to help you until then. There are umpteen tutorials on the net, if you don't understand them its frankly not my problem and this is really simple stuff that you should be able to wrap your head around quite simply.

Go read up on how SQL works then come and ask the question again, I'm not going to help you until then. There are umpteen tutorials on the net, if you don't understand them its frankly not my problem and this is really simple stuff that you should be able to wrap your head around quite simply.

First i did not say it was your problem.

Secondly this is a forum for HELP

That is the whole point of this forum.

If this is your attitude then don't bother coming on this forum, why have a forum if all you going to do i say like what you said above. Someone asking for help and this is what they get, The whole point of this forum and like many others to help each other out.

Some of us have experience some don't. My main priority is learning PHP then MySQL, doing them at the same time is somewhat confusing for me. Everyone is different, for me learning one at a time is less confusing, hence why i come here for help until i do learn, no matter how knowledged we all are we all require help.


Your attitude stinks.

I have this attitude because you wont bother to help yourself. Your correct, this is a help forum, not a handholding forum.

I have this attitude because you wont bother to help yourself. Your correct, this is a help forum, not a handholding forum.

how can you say i am not bothering helping myself?

where did i say that or give that impression?

handholding forum, how come is this now the case? if you read my posts i am asking for help not for you to hold my hand!

I have googled times before but nothing seems to relate to my exact problem or simply does not work.

Most places i look dont give in depth detail in simple terms for newbies to understand properly again hence why i come here.

This question has already been answered. Start a new discussion instead.