Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Querying records 1

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
HI,

I need assistance on querying records. I created a table in my database which stores userID and password information. What I'm trying to do is after the user enters the login information from the form, mysql then checks to see if the information enters exists in the table. This is what I have so for;

$conn=mysql_connect("localhost","kjuuu","cea7")
or die("Could not connect " . mysql_error());
print "Connected successfully";

mysql_select_db("mylogin",$conn) or die("Could not select database");
$sql="SELECT userID FROM logins where userID like '$userID'";

I'm stuck after this.

Do you also use my_sql somewhere?

Thanks
Kyle
 
You need to check that the user name and password match exactly. You should not use a like, instead use something like the following.

Code:
$sql = "select userid from logins where userid='$userid' and password = '$password'";
# If the userid and password match mysql will return the user name, otherwise nothing will be returned.
Code:
$user = "";
while ( $row = mysql_fetch_row() ) {
    $user = $row[0];
}
$logged_in = true if !($user eq "");

Is this PHP script or perl? If perl are you using DBI?

abombss
 
Clue:
So far you have connected to the server, slected a database
defined a query string....
You need to send the query to the MySQL server.
;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top