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

adding up might be solved tell us cheers.
i think i finally solved this anybody.

last time i was getting the wrong results.

Code

styling a RadioButtonList
HiI need to have a radio button and close to it, its lable, then a space then another set of those.

Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co

Random date selection
i want to select random date with time(hour+minutes+sec) where date is specified(10/22/2009) and tim

Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.

If i send the value by this

str_replace help
Hey there,

I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean

please, need help coding this voting for your favorite car polling system.
hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, upda

Sharing PHP Sessions Across Domains
I am in the process of writing a script to share a php session across various domains I have.
The

LinkedList help
Ok so I just learned quickly about lists, so I have a not too hard project I think, but am having a

switch form actions? not working
i want on submit to go to different pages according to the CatID

Code: <?php $CatID=$_

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