Check if the user is activate or not

96 Views Asked by At

Am trying to develop a login/registration system so the user must activate its account. My problem is how to check in the database for the column 'activate' which is 0 if it's not activate and 1 if his/her account is active, plus i want to put an if it's not active to display a message.

$sql2 = "SELECT * WHERE username2='$username2' AND activation=0";
$result2 = mysql_query($sql2);
if($result2=1){
    echo"Please activate your account"; 
}
else{
    echo " ";
}
1

There are 1 best solutions below

0
On

Try this :

public function function_name ($username){
  $this->db->select('*');
  $this->db->from('table_name'); // table_name where you can find the column username and activation
  $this->db->where(array('username' => $username , 'activate' => 0)); // condition use  if the user is active or not

  $query = $this->db->get();
  return $query->return_array(); // you can also use here first_row('array')

}

I hope this helps .