-1

So I have a form that is being submitted to a PHP file. The form contains 2 values ($username & $password) and I would like to compare those values to a MySQL table. First, check if the "username" column has that exact value that $username has (match case and value) and if it does contain it, check the "password" column of that row if it contains the exact value of $password (match case and value). Here's what I am talking about...

PHP Values:

$username = "Billy Bob";
$password = "abc123";

MySQL Table:

id | username  | password
 1 | billY boB | 123aBc
 2 | Billy Bob | abc123

If the username and password matches the column's value, then I want it to return true or false. I'm using PHP's new mysqli(). Can this be done, and if so, what is the query? I am very new to MySQL, so I don't know much.

Jacob Gunther
  • 351
  • 5
  • 14

1 Answers1

0

You are looking for the very basic SELECT query with WHERE clause:

SELECT * FROM `tbl` WHERE `username` = X AND `password` = Y

I really advise you to learn SQL

Dekel
  • 60,707
  • 10
  • 101
  • 129
  • Thank you. I've very new to MySQL.I know the basic SELECT FROM WHERE and how to connect to MySQL databases but as I said I'm new. I've looked through many websites trying to find this but no luck for some reason :( – Jacob Gunther Dec 04 '16 at 01:19
  • Well, I would appreciate it if you can mark the answer as correct (the V on the left to the question). Regarding on how to connect it to the MySQL database - you can start here: http://php.net/manual/en/mysqli.query.php You have several examples there. – Dekel Dec 04 '16 at 01:20