I have this ajax code. data consists of login credentials.
$.ajax({
url: "app/php/login.php",
type: "GET",
data: data,
dataType: 'json',
async: true,
success: function(response){
blah blah
}
})
and here is my login.php. Everytime i sent a request, an alert pops up with the message Something Went Wrong. Am i doing this right? Forgive me for using GET method in a login
header('Content-Type: application/json');
$dbconn = mysqli_connect("localhost","root","","alumni_tracker") or die("Could not connect to database!"); //host, username, password, db
mysqli_select_db($dbconn,"alumni_tracker");
$student_no = $_GET["student_no"];
$password = $_GET["password"];
$query = "SELECT * FROM user WHERE student_no= '$student_no' AND password=MD5('$password')";
$res = mysqli_query($dbconn, $query);
if(empty($res)){
$data = "1";
}
else if(!empty($res) && $student_no == "111111111"){
$data = "2";
}
else{
while($row = mysqli_fetch_array($res)){
$data = array('student_no'=>$row['student_no'],'password'=>$row['password']);
}
}
return json_encode($data);
exit();