Jump to content

[SOLVED] Can someone take a kook at this and tell me what I am missing


affordit

Recommended Posts

<?php

include("sharons_dbinfo.inc.php");

mysql_connect(mysql,$username,$password);

mysql_select_db($database) or die( "Unable to select database");

 

$query = "select * from login WHERE email='$email' and lost_password_answer='$lost_password_answer'";

$result=mysql_query($query) or die (mysql_error());

$num=mysql_numrows($result);

mysql_close();

 

 

$i=0;

while ($i < $num) {

$name=mysql_result($result,$i,"name");

$psword=mysql_result($result,$i,"psword");

$email=mysql_result($result,$i,"email");

$lost_password_answer=mysql_result($result,$i,"lost_password_answer");

$valid=mysql_result($result,$i,"valid");

 

// MAIL THE PASSWORD

 

$to = "$email";

$subject = "Your Password";

$message="You recently requested your password be mailed to you\n Thank you for using our service your password is $psword";

$headers = "From: webmaster@affordit.us";

$sent = mail($to, $subject, $message, $headers) ;

if($sent)

{print "Your password has been sent to $email and it is $psword<br><br><a href='index.php'>Back to main page</a>"; }

else

{print "We encountered an error sending your mail"; }

++$i;

}

?>

Link to comment
Share on other sites

Try something like.

<?php

include("sharons_dbinfo.inc.php");
mysql_connect(mysql, $username, $password);
mysql_select_db($database) or die("Unable to select database");

$query = "SELECT * FROM `login` WHERE `email` = '$email' and `lost_password_answer` = '$lost_password_answer'";
$result = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($result); 
$array = mysql_fetch_array($result);

mysql_close();

if($num == 1)
{
   while ($i < $num)
   {
       $name = $array['name'];
       $psword = $array['psword'];
       $email = $array['email'];
       $lost_password_answer = $array['lost_password_answer'];
       $valid = $array['valid'];

       // MAIL THE PASSWORD
       $to = "$email"; 
       $subject = "Your Password"; 
       $message="You recently requested your password be mailed to you\n Thank you for using our service your password is $psword";
       $headers = "From: webmaster@affordit.us"; 
       $sent = mail($to, $subject, $message, $headers) ;

           if($sent) 
           {
               print "Your password has been sent to $email and it is $psword<br />
                       <a href=\"index.php\">Back to main page</a>"; 
           } else 
           {
               print "We encountered an error sending your mail";
           }
       $i++;
   }
} else
{
   print "The values you enterd were false";
} 
?>

 

Link to comment
Share on other sites

They come from this form

 

<?php

include("sharons_dbinfo.inc.php");

mysql_connect(mysql,$username,$password);

@mysql_select_db($database) or die( "Unable to select database");

 

//

// CHANGE QUERY TO GRAB THE ID

//

$query = "select * from test WHERE email='$email'";

$result=mysql_query($query) or die (mysql_error());

$num=mysql_numrows($result);

 

mysql_close();

 

$i=0;

while ($i < $num) {

$company=mysql_result($result,$i,"company");

$name=mysql_result($result,$i,"name");

$address=mysql_result($result,$i,"address");

$city=mysql_result($result,$i,"city");

$state=mysql_result($result,$i,"state");

$zip=mysql_result($result,$i,"zip");

$phone=mysql_result($result,$i,"phone");

$acct_num=mysql_result($result,$i,"acct_num");

$email=mysql_result($result,$i,"email");

$start_date=mysql_result($result,$i,"start_date");

$end_date=mysql_result($result,$i,"end_date");

$remind_date=mysql_result($result,$i,"remind");

$lost_password=mysql_result($result,$i,"lost_password");

$lost_password_answer=mysql_result($result,$i,"lost_password_answer");

 

echo "$lost_password<br>";

echo "<form action=send_password.php method='POST'><table>";

echo "

<tr>

<td><img src='b_tipp.png' alt='Write your answer to the above question.'>Question:</td><td>$lost_password:</td>

</tr>

<tr>

<td><img src='b_tipp.png' alt='Write your answer to the above question.'>Your Answer:</td><td><input type=text name=lost_password_answer size=30 maxlength=100></td>

</tr>";

echo "<br><tr>

<td align='center' colspan='2'><br><input type=submit name='Submit' value='Send Now'></td>

</tr>

</table>

</form>";

++$i;

}

?>

Link to comment
Share on other sites

Are you sure your entering an email and lost password answer that exists in the database?

 

If you are positive that you are, then echo your query out to make sure the variables are set right.

 

<?php

$query = "SELECT * FROM `login` WHERE `email` = '$email' and `lost_password_answer` = '$lost_password_answer'";
$result = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($result); 

echo "<p>$query<p>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.