frank_solo Posted April 17, 2013 Share Posted April 17, 2013 After the script moves the info into the new database it does not delete the row. <?php include('config.php'); if($_SERVER["REQUEST_METHOD"] == "POST") { // Username from link $username=htmlentities($_GET['username']); $confirm_code=htmlentities($_GET['confirm_code']); $tbl_name1="forgetpass"; // Retrieve data from table where row that match this passkey $sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'"; $result1=mysql_query($sql1); // If successfully queried if($result1){ // Count how many row has this passkey $count=mysql_num_rows($result1); // if found this passkey in our database, retrieve data from table "temp_members_db" if($count==1){ ; $rows=mysql_fetch_array($result1); $username=$rows['username']; }else{ $password=mysql_real_escape_string($_POST['password1']); if(!$_POST["password1"] || !$_POST["password2"]){ $error="Please fill the required fields"; }else if(empty($username)){ $error="No Confirmation Link Sent"; }else if($_POST["password1"] != $_POST["password2"]){ $error="PASSWORDS do not match!"; //validate password length }else if(strlen($_POST["password1"]) < 6){ $error="PASSWORD is too short! Must be 6 characters long"; }else{ $password=$_POST['password1']; // it is acceptable, so hash it $encrypt_password="Some Hashing"; // Insert data into database $sql2="UPDATE user SET password = '$encrypt_password' WHERE username = '$username'"; $result2=mysql_query($sql2); // if suceesfully inserted data into database, send confirmation link to email if($result2){ $status="Your Password Has Been Reset"; // Delete information of this user from table "temp_members_db" that has this passkey $sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$confirm_code'"; $result3=mysql_query($sql3); } } } } } ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 17, 2013 Share Posted April 17, 2013 Look at your SELECT query . . . $sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'"; . . . and your DELETE query $sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$confirm_code'"; notice anything different? Quote Link to comment Share on other sites More sharing options...
frank_solo Posted April 17, 2013 Author Share Posted April 17, 2013 HA! Its late here in NY. Need to go to sleep, but I changed and it still does not delete. This is what I have now: <?php include('config.php'); if($_SERVER["REQUEST_METHOD"] == "POST") { // Username from link $username=htmlentities($_GET['username']); $confirm_code=htmlentities($_GET['confirm_code']); $tbl_name1="forgetpass"; // Retrieve data from table where row that match this passkey $sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='".$confirm_code."'"; $result1=mysql_query($sql1); // If successfully queried if($result1){ // Count how many row has this passkey $count=mysql_num_rows($result1); // if found this passkey in our database, retrieve data from table "temp_members_db" if($count==1){ ; $rows=mysql_fetch_array($result1); $username=$rows['username']; }else{ $password=mysql_real_escape_string($_POST['password1']); if(!$_POST["password1"] || !$_POST["password2"]){ $error="Please fill the required fields"; }else if(empty($username)){ $error="No Confirmation Link Sent"; }else if($_POST["password1"] != $_POST["password2"]){ $error="PASSWORDS do not match!"; //validate password length }else if(strlen($_POST["password1"]) < 6){ $error="PASSWORD is too short! Must be 6 characters long"; }else{ $password=$_POST['password1']; // it is acceptable, so hash it $encrypt_password="Some Hashing"); // Insert data into database $sql2="UPDATE user SET password = '$encrypt_password' WHERE username = '$username'"; $result2=mysql_query($sql2); // if suceesfully inserted data into database, send confirmation link to email if($result2){ $status="Your Password Has Been Reset"; // Delete information of this user from table "temp_members_db" that has this passkey $sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '".$confirm_code."'"; $result3=mysql_query($sql3); } } } } } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 17, 2013 Share Posted April 17, 2013 You're not checking for mysql errors at all. Something somewhere could be failing. Ps: it's generally a good idea to apply a limit 1 to a delete if not using a pm. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 17, 2013 Share Posted April 17, 2013 Pm = pk (thanks iPhone) = primary key 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.