473,769 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5831
On 30 Sep 2003 12:28:18 -0700, r_**********@ya hoo.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_globa ls', 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=strto lower($_POST['user']);
$password=strto lower($_POST['pass']);
$usercheck = mysql_query("SE LECT * FROM customer where
username='$user name' AND password='$pass '",$db);
$userrow = mysql_fetch_arr ay($usercheck);
$num_rows = mysql_num_rows( $usercheck);
if ($num_rows!=1){
print "<p><b>user name 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
3395
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 replied.can someone on this list please help? The issue should be trivial for experienced MySQL users, I'm just a novice, thanks!
0
2017
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 MySQL-server-4.1.0-0.i386.rpm
9
6089
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
3948
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 version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
3
1643
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. Thanks for any help you might be able to give. -Kirk Ok, in the midst of fixing this problem I have somehow managed to create
5
4313
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 I did. It did not work. Here's the error: /usr/bin/mysqladmin: connect to server at 'appserver' failed error: 'Host 'appserver.crci.com' is not allowed to connect to this MySQL server' Another command I'm supposed to run also resulted in an...
5
4571
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 manual said I should write this at the shell: c:\mysql\bin>mysqladmin -u root creare mindb I did this and got this error:
6
38519
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 through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
1
2414
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 Ultimate, I'm using iis7 here is the code of the php. <?php $Username = "Webuser"; $Password = "password"; $Database = "sample"; $Hostname = "localhost"; $MySQLConnection = mysql_connect($Hostname, $Username, $Password) ...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.