I have an Android app which is used to store data of users in MySQL database using PHP. I need to do some validations according to the date.The MySQL Database has a predefined date for each user.The date increases by 1 day whenever a user inserts data twice for that day.And when the date exceeds the current date,it shows a message that "the user has already submitted data for the day".
My PHP file is :
<?php
require "conn.php";
$user_mobile = $_POST["mobile_num"];
$user_pass = $_POST["password"];
$mysql_qry = "select * from employee_data where mobile like '$user_mobile' and password like '$user_pass';";
$result = mysqli_query($conn,$mysql_qry);
if(mysqli_num_rows($result) > 0 ) {
$row = mysqli_fetch_assoc($result);
$name= $row["name"];
$_POST['user'] = $name;
$last_updated = $row["last_updated_date"];
$_POST['user'] = $name;
$_POST['date'] = $last_updated;
echo "Login successful. Welcome_" .$name;
echo "_Date:" .$last_updated;
$now = new DateTime("Asia/Kolkata");
$n = ($now->format('Y-m-d'));
if(($last_updated > $n)) {
echo "exceeded";
}
?>
But what is happening is if "$last_updated"(the date which is changing everytime) is the current date,then it is not going inside the if condition. So if "$last_updated" is today's date, then the user gets the message "the user has already submitted data for the day". I tried doing an echo of "$n" and it gives the current date. So, it should not go to the if-condition because ($last_updated == $n) . But its going inside the if-condition when ($last_updated == $n).I don't know why this is happening.Can anyone please help me with this?
last_updated_datefield data type ?