Problems with PHP and Xampp

Asked

Viewed 119 times

1

I was mounting this api in php linked with xampp following this video(https://www.youtube.com/watch?v=8Ou1ERM2MOw&index=4&list=PLk7v1Z2rk4hjQaV062aE_CW68xgXdYFpV), but even if I follow exactly the video I can’t make it work here... when I take the test in Postman he accuses error, does any know what happens and can help me.

Thanks 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"}

register

<?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;
        }

}
?>

1 answer

4


  • 1

    Man thanks a lot, I’ve seen the shit I’ve done...

  • @Matheusrodrigues if the answer solved the problem please mark it as correct.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.