php mysql api tutorials

Similar Posts

12 Comments

  1. after running signup page it gives me the following reply

    Notice: Undefined index: username in D:\XAMP\htdocs\LOGIN\api\User\signup.php on line 15

    Notice: Undefined index: password in D:\XAMP\htdocs\LOGIN\api\User\signup.php on line 16
    {“status”:false,”message”:”Username already exists!”}

  2. when i am tring to insert record bu ysing signup.php null record means no insert
    // set user property values
    $user->username = $_POST[‘username’];
    $user->password = $_POST[‘password’];

    but when i use

    $user->username = $_GET[‘username’];
    $user->password = $_GET[‘password’];

    INSERT sucessfully. why i am using php 7.1

  3. I have an alternative to login:
    login.php:
    ####################################################
    getConnection();

    // prepare user object
    $user = new User($db);

    // set ID property of user to be edited

    $data = json_decode(file_get_contents(“php://input”));
    $user->username = $data->username;//$contacto->encrypt_decrypt(‘encrypt’, $data->username);
    $user->password = $data->password;//$contacto->encrypt_decrypt(‘encrypt’, $data->password);

    // $user->username = isset($_GET[‘username’]) ? $_GET[‘username’] : die();
    // $user->password = isset($_GET[‘password’]) ? $_GET[‘password’] : die();
    // $user->username = $contacto->encrypt_decrypt(‘encrypt’, isset($_GET[‘username’]) ? $_GET[‘username’] : die());
    // $user->password = $contacto->encrypt_decrypt(‘encrypt’, isset($_GET[‘password’]) ? $_GET[‘password’] : die());

    // read the details of user to be edited

    if($user->login()){
    // get retrieved row
    http_response_code(201);

    // create array
    $user_arr=array(
    “status” => true,
    “message” => “Successfully Login!”,
    “id” =>$user->id ,
    “username” =>$user->username//$contacto->encrypt_decrypt(‘decrypt’,$user->username)
    );
    }
    else{
    http_response_code(503);
    $user_arr=array(
    “status” => false,
    “message” => “Invalid Username or Password!”,
    );
    }
    // make it json format
    echo json_encode($user_arr);
    ?>
    ##########################################################

    user.php:
    ##########################################################
    function login(){
    // select all query
    $query = “SELECT
    `id`, `username`, `password`, `created`
    FROM
    ” . $this->table_name . ”
    WHERE
    username='”.$this->username.”‘ AND password='”.$this->password.”‘”;
    // prepare query statement
    $stmt = $this->conn->prepare($query);
    // execute query
    $stmt->execute();
    if ($stmt->execute()) {
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $this->id = $row[‘id’];
    $this->username = $row[‘username’];
    $this->password = $row[‘password’];
    return true;
    }

    return false;

    }
    ############################################################
    postman or restler client
    {
    “username”:”johndue”,
    “password”:”12345″
    }

  4. thanks a lot sir,
    Sir i want to make android login and signup form can u please tell me how to connect this with my android project

          1. thank you so much sir.. i refered that link after i done some small changes and the api work well.. again thanks sir

Comments are closed.