ngreenwood6 Posted August 4, 2008 Share Posted August 4, 2008 When this gets inserted into the database it blanks out the password. It's almost like the form is getting submitted before i click submit. Another form gets verified from this before the second one. <?php $reset_email = Trim(stripslashes($_POST['reset_email'])); $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="login"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM members WHERE email = '$reset_email'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if($count==1){ $row = mysql_fetch_array($result); } ?> <table> <form name="reset" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <tr> <td><?php echo $row['security']; ?> <td>: <td><input name="answer" type="text"> </tr> <tr> <td>New password <td>: <td><input name="new_pass" type="text"> </tr> <tr> <td><input name="submit" type="submit" value="submit"> </tr> </form> </table> <?php $new_pass = Trim(stripslashes(md5($_POST['new_pass']))); //define the database variables $host = "localhost"; $db_name = "login"; $db_table = "members"; $db_username = "root"; $db_password = ""; //function to insert the data into the database $update_db = "INSERT INTO members (password) VALUES ('$new_pass') WHERE email = '$reset_email'"; //variable to connect to database $mysqli_connect = mysqli_connect($host,$db_username,$db_password,$db_name) or die ("Could not connect to database"); //variable to send data to the database mysqli_query($mysqli_connect,$update_db) or die ("Error: ".mysqli_error($mysqli_connect)); ?> Link to comment https://forums.phpfreaks.com/topic/118145-solved-need-help/ Share on other sites More sharing options...
ngreenwood6 Posted August 4, 2008 Author Share Posted August 4, 2008 Someone here has to know of a way to do an easy password recovery. Link to comment https://forums.phpfreaks.com/topic/118145-solved-need-help/#findComment-607852 Share on other sites More sharing options...
Jabop Posted August 4, 2008 Share Posted August 4, 2008 what Link to comment https://forums.phpfreaks.com/topic/118145-solved-need-help/#findComment-607855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.