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).

Did you know?Explore Trending and Topic pages for more stories like this.
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

Ignore html and bbcode?
I've created a function to limit the amount of text according to the amount of words.

However

DateObject and Nulls
Hi all,

I have an array mapped to a value object. One of the items in the array is a PHP Date

Mail form doesn't send Russian/Cyrillic characters correctly?
When someone enters foreign characters (like Cyrillic text, and Japanese/Chinese probably gives the

How To Make More Than One Redirection with PHP on the same page?
Hey im trying to do a direction page where it open differently link direction pages every time som

Help to integrate whois Domain Details to website
Hi,

can i know is their any php script r methods to add domain details to my website.

Career Change into SAP
Hai
I am sajesh ,did my diploma in Mechatronics i have a 4 years of experience in

Sending an SMS Message with ASP.NET
Often times it may be a requirement for your web application to send an SMS message. Such examples w

Remove directories not empty
hi,
i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder.<

empty() error
Why does

Code: empty($USER_ID = $_SESSION["USER_ID"])
create this error...

Not showing whole name with mail () script
I sent up a simple mail form with the PHP mail() script. One problem is when it sends an email with

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