<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$servername = "localhost";
$username = "strandwe_film";
$password = "p1Fo[6~~0YUq";

try {
  $conn = new PDO("mysql:host=$servername;dbname=strandwe_film", $username, $password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  //echo "Connected successfully";
} catch(PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}


    $username=$_GET['username'];
    $password=$_GET['password'];


    
    $stmt = $conn->prepare("SELECT * FROM `messenger_users` users WHERE username = ? and password=?");
    // $stmt->bindParam(':name', $username);
	// $stmt->bindParam(':pwd', $password);
    $stmt->execute([$username,$password]);
    $data = $stmt->fetch();

    if($stmt->rowCount() > 0){
        echo "exists!";
    } else {
        echo "non existant";
    }
	
	

    
   // $result = mysql_query("SELECT `id` FROM `messenger_users` WHERE username='$username' AND password='$password'");

  /*  if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_array($result);
        $id = array('id' => $row["id"]);
        echo json_encode($id);
    }
    else {
        $id = array('id' => -1);
        echo json_encode($id);
    }
	*/
?>
