php - How to log user browser and separate failed and successful logins to different tables? -
i have code logs date, ip, username , password inputs both failed , successful logins single table.
i want failed logins logs go table instead of logging in 1 table. original code below.
i want log browser using don't know how php.
config login
$link = mysqli_connect("localhost","username","password","database") or die("error " . mysqli_error($link)); <?php if(isset($_post['username']) && empty($_post['username']) === false) { $newusername = mysqli_real_escape_string($link, $_post['username']); $newpassword = mysqli_real_escape_string($link, $_post['password']); $userip = $_server['remote_addr']; $today = date('y-m-d h:i:s'); // write new infos db $query = "insert `userlog` (`username`, `password`, `ip`, `date`) value ('".$newusername."', '".$newpassword."', '".$userip."', '".$today."')"; if($result = $link->query($query)) { // content writen // echo "ip username ".$_post['username'].'<br>'.php_eol; } else { echo "error writing in db, sorry ".$_post['username'].'!<br>'.php_eol; } } ?>
Comments
Post a Comment