Each record in the table has a username, login_date and user_id . it stored in my att_log table.
However, I want to make sure that users can only login once a day. Here my code so far
CODE
<?php
include('conn.php');
if (isset($_POST['submit'])) {
$UserName=$_POST['id_emp'];
$Password=$_POST['password'];
$result=mysql_query("select * from employee where id_emp='$UserName' and password='$Password' )or die (mysql_error());
$count=mysql_num_rows($result);
$row=mysql_fetch_array($result);
if ($count > 0){
$_SESSION['emp_id']=$row['emp_id'];
mysql_query("insert into att_log (username,login_date,id)values('$UserName',NOW(),".$row['emp_id'].")")or die(mysql_error());
include('conn.php');
if (isset($_POST['submit'])) {
$UserName=$_POST['id_emp'];
$Password=$_POST['password'];
$result=mysql_query("select * from employee where id_emp='$UserName' and password='$Password' )or die (mysql_error());
$count=mysql_num_rows($result);
$row=mysql_fetch_array($result);
if ($count > 0){
$_SESSION['emp_id']=$row['emp_id'];
mysql_query("insert into att_log (username,login_date,id)values('$UserName',NOW(),".$row['emp_id'].")")or die(mysql_error());
how do i write a right statement to check case if the user_id have login on the same dates, it will reject, before it being insert into att_log table.
With the current code, it will continuously insert the same user again and again.
Newbie here