I have a php page that contains a submit button, there are 2 ajax requests. The first ajax request submits to password_check.php, which if the password is good, you're done. If its bad, it gives an alert. :
function checkpassword( $password, $error )
{ $.ajax({
type: 'post',
url: 'password_check.php',
data: $password.serialize(),
dataType: "text",
success:
function( data ){
if($error == 0 && data == "good"){
$password.addClass('good');
window.location.href = "finished.php";}
else if( data == "bad" ){
$password.addClass('bad');
alert("Your password is wrong.);}}});
The second ajax request, which always happens regardless of whether the password is good or bad, logs the ip address,name, date and time that the request is made (log_this.php). (These ajax requests are in the same function checkpassword).
var $form= $( ".submit" );
$.ajax({
type: 'post',
url: 'log_this.php',
data: $form.serialize(),
dataType: "text",
success: function(data){},
error:function( data ){}
});
}
Check password function call, where it starts.
checkpassword($(".submit"), $error);
password_check.php:
<?php
// include database $connection file
$user = getuser();
$password = $_POST['submit_form'];
$query = "SELECT password
FROM user_table WHERE person = '$user'";
$returned_value = mysqli_query($connection, $query);
$data = $returned_value->fetch_assoc();
$realpassword = $data['password'];
if($password == $realpassword){ echo "good";}
else { echo "bad"; }
?>
log_this.php:
<?php
// include database $connection file
$user= getuser();
$first = $_POST['first'];
$last = $_POST[ 'last' ] ) );
$password = $_POST['password'];
$ip = $_SERVER['REMOTE_ADDR'];
$long= ip2long($ip);
$query= "SELECT password, first, last FROM user_table
WHERE person = '$user'";
$returned_value = mysqli_query($connection, $query);
$data = $returned_value->fetch_assoc();
$realpassword = $data['realpassword'];
$realfirst = $data['first'];
$reallast = $data['nameLast'];
$is_true = ( $password == $realpassword ) ? true : false;
$correct_name = ( $first == $realfirst && $last == $reallast ) ? true : false;
date_default_timezone_set( 'UK/London' );
$date = date('Y-m-d H:i:s');
$query= "INSERT INTO log_this
(user, first, last, datetime, ip, good_name, good_password, password_entered )
VALUES ('$user','$first','$last','$date','$long','$correct_name','$is_true','$password')";
$returned_value= mysqli_query($connection, $query);
?>
Now my question is, would for any reason, writes not be made or inserted into the log_this table? is there a locking issue? log_this uses innodb but user_table uses myisam. could there be any reason why a write/insert is not made into the log_this table? also note, that log_this does not allow null values.
Thanks for your help.