How to use php and sql to check if values match the ones in a table (for logins)


Posted on 16th Feb 2014 07:03 pm by admin

How would I code it that the script takes two variables that are passed to it (UserID and PIN), and checks the table to see if the PIN matches the one in the table. If it does it should assign the value "1" to a variable, if not a value "2".

This variable should then be passed back to the original calling script. (In a different PHP file).

What I have so far is:
$ID = $_SERVER["argv"][1];
$ID = trim($ID);
$ID = ltrim($ID);

$PIN = $_SERVER["argv"][2];
$PIN = trim($STATUS);
$PIN = ltrim($STATUS);

$link = mysql_connect("localhost", "root", "passw0rd")
or die("Data base connection failed");
mysql_select_db("test")
or die("data base open failed");

I dont know the sql command to compare if the value passed on matches the current record.

Thanks

No comments posted yet

Your Answer:

Login to answer
227 Like 52 Dislike
Previous forums Next forums
Other forums

iterating through an array and escape each value independently.
I have a set up where the variable being escaped is an array and it needs to be iterated and escaped

check if string contain only a-z/A-Z
Is where any way to check if string contains only a-z/A-Z, without writing an array with all possibl

Search with relational database
Hey,

I have quite a complicated (for me anyway ) relational database for an apartments syste

Pro-rata Billing in Periodic Billing for Rental
Hi guys,

We have a situation, where a rental contract starts at the mid of the month say

TimeZoneOffset
Hello,

Please i need your help. I have a system that users can use to punch in and out. This

IS this code correct
The reason i ask is everything underneath it appears to be alink as well, tis blimmin annoying

Weekly Calendar
Hi, I am looking at creating a weekly calendar. The calendar will read from Monday - Sunday. Does an

switch not getting value
what am i doing wrong?
i want to populate the country list according to the category
i want to

Add a sign-up feature to a flat file login script
I'm working on a flat file login script and I would like to add a sign-up feature to it with a email

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash