I am working with PHP and AngularJS, and I have a login.php file, Where it happens the verification of the user, and in this file, I store some information(email,token,..) in a vairable $result to use them in AngularJS. The problem that I have is that I need to store the result of a query in this variable to recuperate in AngularJS as I did for other variable. when I try this code, I recuperate the $cc variable where I stored the query result but, but it doesn't bear the query result , I get this :
cc: {current_field: "", field_count: "", lengths: "", num_rows: "", type: ""}
But in this variable I want to have the result of query. How can I do please?
login.php
<?php
$data = json_decode(file_get_contents("php://input"));
$connect = mysqli_connect("localhost", "root", "", "test");
if(count($data) > 0)
{
$Email=mysqli_real_escape_string($connect, $data->Email);
$mdp=mysqli_real_escape_string($connect, $data->mdp);
$query = 'SELECT * FROM client ';
$q = mysqli_query($connect , $query);
if(mysqli_num_rows($q) > 0 )
{
$token = md5($Email.time()."51395+81519851");
$query2 = "UPDATE client SET token = '".$token."' WHERE EmailClient = '".$Email."'";
mysqli_query($connect , $query2);
$_SESSION["logged_in"] = true;
$_SESSION["token"] = "51395+81519851";
$_SESSION["Email"] = $Email;
;
$result['email'] =$Email;
$result['role'] = 'client';
$result['token'] = $token;
$result["cc"] = $q ;
$resultstring=json_encode($result);
$resultstring=str_replace("null", '""', $resultstring);
echo $resultstring;
exit;
}