affordit Posted January 30, 2008 Share Posted January 30, 2008 <?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: [email protected]"; $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 https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/ Share on other sites More sharing options...
pocobueno1388 Posted January 30, 2008 Share Posted January 30, 2008 How are we supposed to find whats missing when we don't even know what to look for? Do you get an error or anything? Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453568 Share on other sites More sharing options...
affordit Posted January 30, 2008 Author Share Posted January 30, 2008 SORRY ABOUT THAT NO NO ERRORS JUST A BLANK PAGE Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453573 Share on other sites More sharing options...
only one Posted January 30, 2008 Share Posted January 30, 2008 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: [email protected]"; $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 https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453586 Share on other sites More sharing options...
affordit Posted January 30, 2008 Author Share Posted January 30, 2008 No that doesn't work it comes back with data entered false. Thanks Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453599 Share on other sites More sharing options...
pocobueno1388 Posted January 30, 2008 Share Posted January 30, 2008 No that doesn't work it comes back with data entered false. Thanks Well, that means your query is returning no rows. Where are you getting the variables $email and $lost_password_answer from? I don't see them defined before you use them in your query. Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453606 Share on other sites More sharing options...
affordit Posted January 30, 2008 Author Share Posted January 30, 2008 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 https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453618 Share on other sites More sharing options...
pocobueno1388 Posted January 30, 2008 Share Posted January 30, 2008 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 https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453635 Share on other sites More sharing options...
tigomark Posted January 30, 2008 Share Posted January 30, 2008 mysql_connect(mysql,$username,$password); wouldn't that need to be mysql_connect([color=red][font=Verdana]$mysql[/font][/color],$username,$password); to match what ever your mysql value would be (unless this is your host name)? Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453650 Share on other sites More sharing options...
trq Posted January 30, 2008 Share Posted January 30, 2008 They come from this form If your variables are being posted to your script they will be within the $_POST[] array. They don't just magically appear. Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453652 Share on other sites More sharing options...
affordit Posted January 30, 2008 Author Share Posted January 30, 2008 I got it the $email was coming from another page and I didn't make sure t was set Thanks all Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453660 Share on other sites More sharing options...
pocobueno1388 Posted January 30, 2008 Share Posted January 30, 2008 Please don't forget to press the "Topic Solved" button. Link to comment https://forums.phpfreaks.com/topic/88592-solved-can-someone-take-a-kook-at-this-and-tell-me-what-i-am-missing/#findComment-453670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.