Of course I'm a newbie or I wouldn't need to ask this but I'm having trouble getting the following code to work. However, it does work until I include the bit of code
Code: Select all
if (mysql_num_rows($result) > 0)
{Code: Select all
else
{
echo "no records!";
}Code: Select all
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form method="POST" action="">
Search User: <input type="text" name="email">
<input type="SUBMIT" value="Search!">
</form>
<?
include 'library/config.php';
include 'library/opendb.php';
$email=$_POST['email'];
$sql = mysql_query("SELECT firstname, email, password FROM stories WHERE email = '$email'") or die (mysql_error());
$result = mysql_query($query) ;
if (mysql_num_rows($result) > 0)
{
while(list( $firstname, $email, $password)=mysql_fetch_array($sql)){
//change this to your email.
$to = "$email";
$from = "info@pavementmemors.com";
$subject = "Your Lost Pavement Memoirs Username & Password";
//begin message
$message = <<<EOF
<html>
<body>
Hello $firstname,<br>
<br>
Here is your password and email.
<br><br>
Username: $email<br>
Password: $password<br>
<br>
Keep in mind each time you edit your post, the new submission will not be viewable until it’s reviewed to keep the site PG rated.
<br><br>
Sincerely,<br>
Gary
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to, $from"; // this will send to both emails at the same time.
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Results sent to: $email<br />";
}
else
{
echo "no records!";
}
?>
</body>
</html>Code: Select all
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form method="POST" action="">
Search User: <input type="text" name="email">
<input type="SUBMIT" value="Search!">
</form>
<?
include 'library/config.php';
include 'library/opendb.php';
$email=$_POST['email'];
$sql = mysql_query("SELECT firstname, email, password FROM stories WHERE email = '$email'") or die (mysql_error());
$result = mysql_query($query);
while(list( $firstname, $email, $password)=mysql_fetch_array($sql)){
//change this to your email.
$to = "$email";
$from = "info@pavementmemors.com";
$subject = "Your Lost Pavement Memoirs Username & Password";
//begin message
$message = <<<EOF
<html>
<body>
Hello $firstname,<br>
<br>
Here is your password and email.
<br><br>
Username: $email<br>
Password: $password<br>
<br>
Keep in mind each time you edit your post, the new submission will not be viewable until it’s reviewed to keep the site PG rated.
<br><br>
Sincerely,<br>
Gary
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to, $from"; // this will send to both emails at the same time.
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Results sent to: $email<br />";
}
?>
</body>
</html>