我希望您能帮助我理解有关我的代码的一些信息。
我正在创建一个User findOneByEmail(String email);
和android app
表单的Login
。
我需要通过添加Registration
编辑PHP
文件。
我能够将PDOs
文件用于PHP
,但是有问题。
当用户PDO
时,他的registers
和name
被保存在surname
中,并且每次访问怪物时都被保存。
问题在于,由于我通过添加SharedPreferences
来修改PHP
文件,因此,例如,如果我使用PDO
访问,它将显示{{1}的名字和姓氏},如果我使用user1
,user2
登录,user2
总是向我显示user3
的名称和姓氏。
为什么?
使用没有user4
的{{1}}文件,它显示了我登录的用户的姓名和姓氏。
谁能解释为什么会这样?
没有PDO的Login.php
user2
使用PDO的Login.php
PHP
ParseContent.java
PDO
PreferenceHelperRistoratore
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
// echo $_SERVER["DOCUMENT_ROOT"]; // /home1/demonuts/public_html
//including the database connection file
include_once("config2.php");
$idAKr = $_POST['idAKr'];
$cell = $_POST['cellulare'];
if( $idAKr == '' || $cell == '' ){
echo json_encode(array( "statusr" => "false","message" => "Inserisci numero di telefono!") );
}else{
$query= "SELECT * FROM Ristoratori WHERE cellulare='$cell'";
$result= mysqli_query($con, $query);
if(mysqli_num_rows($result) > 0){
$query= "SELECT * FROM Ristoratori WHERE cellulare='$cell'";
$result= mysqli_query($con, $query);
$emparray = array();
if(mysqli_num_rows($result) > 0){
while ($row = mysqli_fetch_assoc($result)) {
$emparray[] = $row;
}
}
echo json_encode(array( "statusr" => "truer","message" => "Accesso eseguito", "datar" => $emparray) );
}else{
echo json_encode(array( "statusr" => "false","message" => "Numero di telefono sbagliato!") );
}
mysqli_close($con);
}
} else{
echo json_encode(array( "statusr" => "false","message" => "Errore, riprova!") );
}
?>
Login.java
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
// echo $_SERVER["DOCUMENT_ROOT"]; // /home1/demonuts/public_html
//including the database connection file
require_once('db.php');
$idAKr = $_POST['idAKr'];
$cell = $_POST['cellulare'];
if( $idAKr == '' || $cell == '' ){
echo json_encode(array( "statusr" => "false","message" => "Inserisci numero di telefono!") );
}else{
$conn=$dbh->prepare("SELECT cellulare FROM Ristoratori WHERE cellulare=?");
$conn->bindParam(1,$cell);
$conn->execute();
if($conn->rowCount() !==0){
$conn2=$dbh->prepare("SELECT COUNT(cellulare) FROM Ristoratori WHERE cellulare=?");
$conn2->bindParam(1,$cell);
$conn2->execute();
$data_exists = ($conn2->fetchColumn());
$emparray = array();
if($data_exists > 0){
$emparray = $conn->fetchAll(PDO::FETCH_ASSOC);
}
echo json_encode(array( "statusr" => "truer","message" => "Accesso eseguito", "datar" => $emparray) );
} else{
echo json_encode(array( "statusr" => "false","message" => "Numero di telefono sbagliato!") );
}
}
$dbh = null;
} else{
echo json_encode(array( "statusr" => "false","message" => "Errore, riprova!") );
}
?>