Hey, i tried to make a script that will selct some info from a user database and send it to the user with the email, but it dosent really work, my code is here
<?
$username="root";
$password="";
$database="members";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM users";
$result=mysql_query($query);
$num=mysql_numrows($result);
$query = mysql_query("SELECT username FROM users");
$num_rows = mysql_num_rows($query);
if(!$email_address){
echo "You forgot to enter your Email address<br />";
include 'resend.html';
exit();
}
// quick check to see if record exists
$sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'");
$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){
echo "No records found matching your email address<br />";
include 'resend.html';
exit();
}
$userid=mysql_result($result,$i,"userid");
$db_password=mysql_result($result,$i,"password");
$subject = "Your Activation code!";
$message = "Hi, we have reset your Activation Code.
Please click the link belov
[url]http://www.domain.com/members/activate.php?id=[/url]$userid&code=$db_password
[url]http://www.domain.com[/url]
Thanks!
The Webmaster
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: Support <support@domain.com>\nX-Mailer: PHP/" . phpversion());
echo "Your Activation code has been sent! Please check your email!<br />";
include 'resend.html';
?>
My form:
<form name="form1" method="post" action="resend.php">
<table width="50%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td>Please enter your email address</td>
<td><input name="email_address" type="text"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Resend activation email!"></td>
</tr>
</table>
</form>
It just select the first entry in the database, not matter witch email you enter in the form.
Any one have a suggestion th why ?