473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

MySQL PHP Password Checker

Can anyone please lend me a hand,
I'm trying to design a cookie based password system.
I have managed to do everything bar one thing that is driving me
crazy.
I have a MYSQL database called "PassworDB" which has a table in it
called "auth",
this table has the columns "user_id" (this is an auto incrementing
number) "user" (meant for the users name) and "password".

All I'm trying to do is search through the results of a MYSQL query
"Select * from pages where user = '$form_user'" ($form_user being
generated from a html form), and compare it to $form_pass (again
generated by the html form) for verification that the user exists in
my database and has supplied the correct password.

I have tried loop's foreach's while statements and all sorts but don't
seem to be able to crack it.

I am quite new to the language so I'm sure it's just the way I'm
trying to do it. If anyone can give me an example or even just tell
me the best way to do it would be really appreciative....

CHEERS......
Jul 17 '05 #1
3 5817
On 30 Sep 2003 12:28:18 -0700, r_**********@yahoo.com (Richard M) wrote:
Can anyone please lend me a hand,
I'm trying to design a cookie based password system.
I have managed to do everything bar one thing that is driving me
crazy.

I have a MYSQL database called "PassworDB" which has a table in it
called "auth",
this table has the columns "user_id" (this is an auto incrementing
number) "user" (meant for the users name) and "password".

All I'm trying to do is search through the results of a MYSQL query
"Select * from pages where user = '$form_user'" ($form_user being
generated from a html form), and compare it to $form_pass (again
generated by the html form) for verification that the user exists in
my database and has supplied the correct password.
Do $form_user and $form_pass actually have values? Global variables from forms
are not generated by PHP's default and recommended configuration, as of many
versions ago. There's plenty of out-of-date tutorials and books out there that
still use it. Search for 'register_globals', and replace any form global
variables with $_GET['form_user'] or $_POST['form_user'] depending on the form
method.
I have tried loop's foreach's while statements and all sorts but don't
seem to be able to crack it.


It's usually best to post your best effort, as it proves you've put some
effort in before asking: and you're probably closer than you think to solving
it in the first place. It's easier for people to post a couple of corrections
to an existing broken script than writing it up from scratch.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2
I noticed that Message-ID:
<ac**************************@posting.google.com > from Richard M
contained the following:
All I'm trying to do is search through the results of a MYSQL query
"Select * from pages where user = '$form_user'" ($form_user being
generated from a html form), and compare it to $form_pass (again
generated by the html form) for verification that the user exists in
my database and has supplied the correct password.


Use the query to check it rather than the php. If the username and
password both exist (you do check at least one of them is unique don't
you?) then the query will only return one row.

This code receives parameters from another page.

$username=strtolower($_POST['user']);
$password=strtolower($_POST['pass']);
$usercheck = mysql_query("SELECT * FROM customer where
username='$username' AND password='$pass'",$db);
$userrow = mysql_fetch_array($usercheck);
$num_rows = mysql_num_rows($usercheck);
if ($num_rows!=1){
print "<p><b>username and/or password not found. Try
again?</b></p>";

else{retrieve details or do other stuff}
?>
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Andy.. Cheers for the advise, I can see why you say to post my best
effort. I will do in the future..

Geoff... Bang on.. that's brilliant, don't know why I didn't thing of
using a SQL statement to do the hard work, makes it all run a dam
sight better as well.
Mucho thanks to both of you.......
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
0
by: craig | last post by:
RH 9. # ./bin/safe_mysqld & 15246 # Starting mysqld daemon with databases from /usr/local/mysql/data 030929 19:42:54 mysqld ended this is what I just installed # rpm -iv...
9
by: ruud | last post by:
I just installed MySQL server 3.23.58-1. Now I can't find the password en can's change the settings. Who knows this password?
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
3
by: Kirk Soodhalter | last post by:
Hi, This started as a phpmyadmin problem, but has somehow morphed into a mysql problem. I don't know how to fix it. I am posting the conversation from a php newsgroup since it started there. ...
5
by: MLH | last post by:
I'm supposed to set a password for the MySQL root user. The output of mysql_install_db instructed me to run the following commands... /usr/bin/mysqladmin -u root -h appserver password mynwewpasswd...
5
by: news.telia.net | last post by:
Hi! I have a question. I have installed php and mysql on an apache-server on windows and I can't connect to the server. I tried to create a database (since I am trying to learn howto). My...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
1
by: chanshaw | last post by:
Alright so I got php running and installed i have mysql running and installed the thing im having a hard time with is having the php to call information from the mysql database. Im on Windows Vista...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.