Click to See Complete Forum and Search --> : Php mail()


DaMasta
07-25-2001, 10:39 AM
I have a php script that will email a user a lost password. Exim is installed and functional. When the user enters their username and email address, it grabs their info from a db and if their email address matches their username, it emails them their password. This is all fine and dandy but I have a little problem. When the user clicks the submit button, the browser says connected to 127.0.0.1 (I'm just beta testing from my home) and just sits there. It does send the email. It never displays my html file that says "your password has been sent to your email". This used to work for me but has recently stopped. Any ideas?

Salmon
07-25-2001, 12:57 PM
got code?

DaMasta
07-25-2001, 01:07 PM
<html>
<title>Lost Password</title>
<head><center><img src="../images/teknospy2.gif" width="600" height="85"></center></head>
<body bgcolor="#999999">
<table align="center" bgcolor="#FFFFFF">
<tr>
<td><form action="forgotpwd.php" method=post>
<b>Username</b></td>
<td><input type=text Name="Username" size=20 style="background:#333333;color:#FFFFFF"></td>
</tr>
<tr>
<td><b>Email</b></td>
<td><input type=text Name="Email" size=20 style="background:#333333;color:#FFFFFF"></td>
</tr>
<tr>
<td> </td>
<td colspan=3><input type=submit name="Submit" value="Submit!"></td>
</tr>
</font>
</center>
</b>
</form>
<?php
include "usersdb.php";
if($Username && $Password) {
$User_Query = "SELECT * FROM $TableName WHERE Nick='$Username' and Email='$Email'";
$User_Result = mysql_db_query($DBName, $User_Query, $Link) or die ("Couldn't execute query.".mysql_error());
while ($row = mysql_fetch_array($User_Result)) {
$Nick_Test = $row['Nick'];
$Email_Test = $row['Email'];
$Pass_Test = $row['Password'];}
if ($Username==$Nick_Test && $Email==$Email_Test) {
print "Your password has been emailed to you.";
mail("$Email", "Password Recovery", "Your password is $Pass_Test");}
else {
print "Your password does not match your username";}}
?>
</body>
</html>


[ 25 July 2001: Message edited by: DaMasta ]

Salmon
07-26-2001, 09:01 AM
The code looks OK at first glance. In the snippet you posted, your HTML is missing a closing </table> tag though, which will cause many browsers not to display the page. This could be the cause of no output (or the appearance thereof). Try looking at the document source with your browser, or just put in the missing tag and run the script again.

You should also consider using the 'From' and 'Return-Path' headers in your 'mail()' call.

DaMasta
07-26-2001, 10:05 AM
The </table> didn't help. Thanks though. I believe it is either a problem with exim or get this system in general. I plan to add the from to mail() eventually. Once again, thanks for your help.