Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to write a code for deactivating users account by fetching the details from login.php page. please anyone help me

login.php code:-

//html code for login form...
if(isset($_POST['Login']))
{
$name= $_POST['uname'];
$pwd= $_POST['pswd'];
$chkname="select * from ".USREG." where email='".$name."' and password='".$pwd."'";
$res=mysql_query($chkname, $con) or die(mysql_error());
$chkresult=mysql_fetch_array($res);
if($chkresult)
{
$_SESSION['uid']=$chkresult['id'];
$_SESSION['username'] = $chkresult['name'];
$_SESSION['umailid'] = $chkresult['email'];
echo '<META http-equiv="refresh" content="0;URL='.INDEX_URL.'booksIns.php">';

}
else
{
echo "Invalid Login";
}
}
?>
Posted
Comments
ZurdoDev 27-Jan-15 10:30am    
Where are you stuck exactly?
Member 11406049 27-Jan-15 11:59am    
fetching current user data i.e emailid or username from database to perform required operations @RyanDev
Member 11406049 27-Jan-15 12:11pm    
below I shared my deactive.php page please take a look. if you want i can share 'myaccount.php' page, i am confusing that from where to fetch user details whether I am want to fetch details from myaccount.php page or from login.php page, and i am beginner in php. @RyenDev

1 solution

PHP
include 'connections.php'; //db connections
$getData="select * from ".USREG." where email='".$_SESSION['username']."'";// here i am facing main problem I don't know how to fetch current user data 


$reslt=mysql_query($getData, $con) or die(mysql_error());
$rows=mysql_fetch_array($reslt);
if($reslt)
{
        $count=mysql_num_rows($reslt); 
	if($count==1)
{

               $rows=mysql_fetch_array($result);
             
		$name = $rows['name'];
		$email=$rows['email'];
		$password=$rows['password'];
		$phone = $rows['phone'];
		$address=$rows['address'];
		$dob=$rows['date_of_birth'];
		$education=$rows['education'];
                
		$tbl_name2='users';
		$sql2="INSERT INTO ".UTEMP."(name, email, password, phone, address, date_of_birth, education)VALUES('".$name."', '".$email."', '".$password."', '".$phone."', '".$address."', '".$dob."','".$education."') ";// main idea is not to delete users account permanently. hence I am trying to store details in one temp_table. If again users needs to activate we reactivate his/her account. its just like backup I don't know how to implement this
                
		$result2=mysql_query($sql2,$con) or die (mysql_error());
               
}
	}
	else 
	{
           
               echo "Deactivation failed";
                        
	}

	if($result2)
	{
		echo " your account has been successfully deactivated for reactivation please contact with our admin";
		$sql3="DELETE FROM ".USREG." WHERE confirm_code='$email'";// deleting users data from main table
		$result3=mysql_query($sql3,$con) or die (mysql_error());
        
	}                   
}
?>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900