View Single Post
  #1 (permalink)  
Old 09-05-2008, 12:36 PM
brentjlaf's Avatar
brentjlaf brentjlaf is offline
WebProWorld Member
 
Join Date: Apr 2007
Location: canada
Posts: 40
brentjlaf RepRank 1
Default Retrieve Username Help

Can't seem to find the bug in here



//Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");

// value sent from form
$email_to=$_POST['email_to'];


// retrieve password from table where e-mail = $email_to(email@home.com)
$sql="SELECT username FROM proteam WHERE email='$email_to'";
$result=mysql_query($sql);

// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysql_num_rows($result);

// compare if $count =1 row
if($count==1){

$rows=mysql_fetch_array($result);

// keep password in $your_password
$your_password=$rows['username'];

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email_to;

// Your subject
$subject="Your username here";

// From
$header="from: your name <info@silvercup.ca>";

// Your message
$messages= "Your username for login to our website \r\n";
$messages.="Your username is $your_password \r\n";
$messages.="more message... \r\n";

// send email
$sentmail = mail($to,$subject,$messages,$header);

}

// else if $count not equal 1
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your username Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send username to your e-mail address";
}
__________________
http://www.tnerb.com
Reply With Quote