出现空白屏幕且下面没有错误,代码连接也很好,无法识别问题以及通过该脚本插入互联网数据上可用的脚本进行检查。
插入所有参数enter image description here
<?php
include_once 'connection.php';
header('Content-Type: application/json');
class user{
private $db;
private $connection;
function __construct(){
$this -> db = new DB_Connection();
$this -> connection = $this->db->getConnection(); //to connect to database
}
public function register($email,$phoneno,$fname,$lname,$gender,$password){
$query = "insert into register(email, phoneno, fname, lname, gender, password) values ( '$email','$phoneno','$fname','$lname','$gender','$password')"; //insertion
$inserted = mysqli_execute($this -> connection,$query);
if($inserted == 1){
$json['success'] = 'Account created';
}else{
$json['failure'] = 'wrong password';
}
echo json_encode($json);
mysqli_close($this -> connection);
}
}
$nuser = new user();
if(isset($_POST['email'],$_POST['phoneno'],$_POST['fname'],$_POST['lname'],$_POST['gender'],$_POST['password'])){
$email = $_POST['email'];
$phoneno = $_POST['phoneno'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$password = $_POST['password'];
if(!empty(email)&& !empty(password)){
$nuser->register($email,$phoneno,$fname,$lname,$gender,$password);
}else{
echo json_encode("fill all fields");
}
}
?>
答案 0 :(得分:0)
点击页面顶部的ini_set("display_errors", 1);
。可能会禁用错误显示。
我认为问题出在这一行。
if(!empty(email)&& !empty(password)){
您忘记了$
签名