what will be the code of comparing the login data with the already stored data of user on the data base .kindly reply me soon.ihv to compare the two variables(user name and password).plzzz
bsse007
-3
Light Poster
Recommended Answers
Jump to PostWhat code do you have so far? You'll be using $_POST variables. Are you using a password hash like md5? More info please.
You compare with a SELECT query, placing the cleaned variables in the WHERE clause.
Jump to PostOK. I see.
$name = mysql_real_escape_string($_POST['user']); $pw = mysql_real_escape_string($_POST['password']); $r = mysql_query("SELECT user_name FROM user WHERE user_name='$name' AND password = '$pw'"); if(mysql_num_rows($r)>0){ //user exists - keep data in session/cookie or whatever }else{ //failed login }
There could be a lot more involved - but this is bare …
Jump to Postthanks a lot.you have solved my problem.
will u plz tell me about "mysql_real_escape_string",infact i have no idea.Sure, when you get raw data from a form (or a url querystring) - the data you pick up from $_POST or $_GET variables in other words, you can't trust the data …
Jump to PostYou need to supply your table structures. SO that we know how they can be linked.
All 14 Replies
furqan219
-9
Junior Poster in Training
bsse007
-3
Light Poster
furqan219
-9
Junior Poster in Training
bsse007
-3
Light Poster
diafol
bsse007
-3
Light Poster
bsse007
-3
Light Poster
diafol
bsse007
-3
Light Poster
diafol
bsse007
-3
Light Poster
diafol
rajarajan2017
bsse007
-3
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.