Hi guys, I really need your help. I am Programming an app where a teacher logs in with a username and password. After the login a new Fragment in the app opens where the Teacher see all his students in a ListView. To Login I only type the username and the password . I use for this php and mysql. My problem is that my login.php don't pass the ID from the teacher to the get_data.php where I do a SQL query. I just started with programming so please be patient.
My login.php:
<?php
session_start();
if($_SERVER['REQUEST_METHOD']=='POST'){
$username = $_POST['username'];
$password = $_POST['password'];
$Teacher_ID= $_GET['Teacher_ID'];
if($username == '' || $password == ''){
echo '';
}else{
require_once('dbConnect.php');
$sql = "SELECT ID_Teacher, username, password FROM Teacher WHERE username='$username' and password='$password'";
$check = mysqli_fetch_array(mysqli_query($con,$sql));
}
if(isset($check)){
echo "succes";
}else{
echo "wrong username or password";
}
}else{
echo "error try again";
}
My get_data.php:
<?php
session_start();
require_once('dbConnect.php');
$_GET['Lehrer_ID'] = $id;
$sql = "SELECT Student.Name,Student.Surname FROM Student WHERE Student.ID_Teacher = .$id";
$res = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($res))
{
array_push($result,
array('Name'=>$row[0], 'Surname'=>$row[1]));
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
?>