I have created registration page and when user click submit button, an activation link is sent to his email and accordingly timestamp is stored in the database. If user click that activation link, I have to check whether that link is clicked before or after 24 hours . my code :-
function confirmEmail($activation_code){
$this->load->database();
$this->load->helper('date');
echo "activation link will be checked and accordingly flag will be set.";
$activation_sent_timestamp=$this->db->query("SELECT activation_timestamp FROM tbl_user_registration WHERE email_verification_code='$activation_code'");
foreach($activation_sent_timestamp->result() as $res){
$activation_time_from_db=$res->activation_timestamp;
}
echo $activation_time_from_db."\n\r";
$now = time();
$human = unix_to_human($now);
echo $human;
$difference = ($human-$activation_time_from_db);
if($difference < 24) {
echo "correct"
}
else echo "Link expired";
}
I am using codeigniter. How can I do this, this code isnot showing any erros but I dont know is this the right way to calculate 24 hours, I am checking but didnt get anything.please check the code.
SOLVED........ :)