Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

 PHP login, allow only once a day

views
     
TSM15T
post Jun 23 2015, 10:58 PM, updated 9y ago

New Member
*
Junior Member
16 posts

Joined: Jul 2013
I have a system which users login to it. Every time a specific user logs in, I store the login date time in a MySQL db using TIMESTAMP:

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());


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 icon_question.gif
angch
post Jun 23 2015, 11:57 PM

On my way
****
Junior Member
635 posts

Joined: Jul 2006
ಠ_ಠ

https://forum.lowyat.net/topic/3398408

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0113sec    0.34    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 10:12 PM