mikebyrne Posted March 31, 2008 Share Posted March 31, 2008 Im coding a password retrival box for my site but instead of running the php the page just loads member_login.php when I press the send password button. my code is: <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" name="login_form" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="password.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form> Password.php looks like <? $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="admin"; // Database name //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['passwordreminder']; // table name $tbl_name=adminusers; // retrieve password from table where e-mail = $email_to(mark@phpeasystep.com) $sql="SELECT password FROM $tbl_name 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['password']; // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email_to; // Your subject $subject="Your password here"; // From $header="from: your name <your email>"; // Your message $messages= "Your password for login to our website \r\n"; $messages.="Your password 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 Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 31, 2008 Share Posted March 31, 2008 Pretty hard to tell with your indentation but it seems to me you have a form within a form. This is invalid html. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted March 31, 2008 Share Posted March 31, 2008 <input type="submit" value="Login »" name="login_form" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="password.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form> form closes inside a form Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 31, 2008 Author Share Posted March 31, 2008 Im still not sure why its not going to password.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.