I am trying to implement a simple javascript program in which I am making an ajax call to a php script. I make sure that the page is not getting refreshed on its own.So,now if I am using echo functions in php then it is not working.
$("#check").on('click',function(){
//alert("hello");
var user_name=document.getElementById("user_name").value;
var pwd=document.getElementById("pwd").value;
$.ajax({
url:'checkUser.php',
type:'POST',
data:{
user_name:user_name,
pwd:pwd
},
success:function(){
alert("hello"); //This section works fine so the php file is getting called
}
});
return false;
})
checkUser.php
<?php require 'database.php';
if($conn->connect_error){
die("Connection failed: " . $conn->connect_error);
}
//Database is getting connected properly
$user_name=$_POST['user_name'];
$password=$_POST['pwd'];
echo("<script>console.log('PHP:');</script>"); //not getting displayed on console
$sql="Select * from login where User_name='$user_name' and Password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
echo $count; //not getting displayed on console
?>
If I want to use an echo function, then how should I do it?Thanks!