<?php
$username=strip_tags($_POST['username']);
$password=strip_tags($_POST['password']);
$username=stripslashes($username);
$password=stripslashes($password);
$username=mysqli_real_escape_string($dbc,$username);
$password=mysqli_real_escape_string($dbc,$password);
$password=md5($password);
$sql="SELECT * FROM mobile_users WHERE username='$username' LIMIT 1 ";
$query=mysqli_query($dbc, $sql);
$row=mysqli_fetch_array($query);
//$expire=time() +60*60*24*30;
//setcookie("");
//}
$id=$row['idmobile_users'];
$db_password=$row['password'];
$_SESSION['error'] = "could not connect";
if($password==$db_password){
$_SESSION['username']=$username;
$_SESSION['id']=$id;
$_SESSION['last_time']=time();
header("Location: apply_now.php");
}
else {
echo 'Invalid username or password';
}
}
?>
<script>
$(function(){
$(document).on("click", ".button", function(e) {
e.preventDefault();
{
//This will capture all the inputs from the form
var infom = $("#myform").serialize();
//$("#showresult").addClass('loader');
$.ajax({
beforeSend: function() { },
type: "POST",
url: "login.php",
data:infom,
success: function(result){
//$("#showresult").removeClass('loader');
$('#showresult').html(result);
}
});
e.preventDefault();
}
});
});
</script>
ok so i want it to place the error message from the php code where the id is in html, the id is in a span tag. Tried alot of ways but cant seem to get it working properly. I hope somone can help me resolve this issue. Thanks
$sql="SELECT * FROM mobile_users WHERE username='$username' LIMIT 1 ";you are not checking the password? out curiosity