Problems with PHP and Xampp [closed]

1

I was putting this api in php connected with xampp following this video ( link ), but even if I follow exactly the video I can not make it work here ... when I do the test in postMan it accuses error, does anyone know what happens and can help me.

Thank you in advance for the help ...

Error

Notice: Undefined index: RESQUEST_METHOD in 
C:\xampp\htdocs\Android\v1\registerUser.php on line 8
{"error":true,"message":"Erro no request 404"}

registerUser

<?php
require_once '../includes/DbOperations.php';
$response = array();

if($_SERVER['RESQUEST_METHOD']=='POST'){
if(
    isset($_POST['username']) and
        isset($_POST['password']) and
            isset($_POST['email'])
    ){

        $db = new DbOperations();

        if($db->createUsuario(
            $_POST['username'],
            $_POST['password'],
            $_POST['email']))
        {
            $response['error'] = false;
            $response['message'] = "Usuario Registrado com sucesso";
        }
        else
        {
            $response['error'] = true;
            $response['message'] = "Desculpe ocorreu um erro";
        }
}   
else
    $response['error'] = true;
    $response['message'] = "Required falha";
}
else
{
$response['error'] = true;
$response['message'] = "Erro no request 404";
}
echo json_encode($response);
?>

DbOperations

<?php

class DBOperations{

    private $con;

    function __construct(){

        require_once dirname(__FILE__).'/DbConnect.php';
        $db = new DbConnect();

        $this->con = $db->connect();

    }

    /*CRUD-> C-> Create */

    function createUsuario($username,$senha,$email){

        $password = md5($pass);
        $stmt = $this->con->prepare("INSERT INTO 'usuario' ('id', 'username', 'password', 'email') VALUES (NULL, ?, ?, ?);");
        $stmt->bind_param("sss",$username,$senha,$email);
        if($stmt->execute()){
            return true;
        }
        else
        {
            return false;
        }
    }
}   

?>

DbConnect

<?php

class DbConnect{

        private $con;

        function __construct(){

        }

        function connect(){
            include_once dirname(__FILE__).'/
                Constants.php';
            $this->con = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);    
            if(mysqli_connect_errno()){
                echo "Erro ao conectar ao database".mysqli_connect_err();
            }   

            return $this->con;
        }

}
?>
    
asked by anonymous 20.01.2017 / 04:25

1 answer

4

Your problem is not with Xampp, you wrote the name of the wrong variable, RESQUEST_METHOD does not exist, the correct one is REQUEST_METHOD , like this:

if($_SERVER['REQUEST_METHOD']=='POST'){

See in the PHP documentation itself how to spell the names link

    
20.01.2017 / 04:30