Jump to content

Can't get it to delete


frank_solo

Recommended Posts

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);

 

} } } } } ?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/277035-cant-get-it-to-delete/
Share on other sites

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);
			
		}
			}
				}
					}
						}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.