473,406 Members | 2,705 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,406 software developers and data experts.

How to use password authentication in php

Hi,
I am new to php. Can any body tell me how many tables to be created in the database in order to use password authentication in php.
What should be the query to maintain uniqueness of user name and to confirm password.
Sep 23 '07 #1
1 1515
Atli
5,058 Expert 4TB
Hi Anoop.

You would have to create a table for the user names, which should be a unique field, and the password, which should be hashed. This table can obviously have more fields if you want it to.

The password field should not contain the actual password, but rather a hashed version. This is for security reasons, so nobody, not even you, can steal the passwords (without a huge effort at least). Not even if they manage to steal the server computer!

So assuming you use MySQL the table could look like this:
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `User` (
  2.   UserID Int Unsigned Auto_Increment Not Null,
  3.   UserName VarChar(150) Not Null UNIQUE,
  4.   Password Char(40) Not Null
  5. )
  6.  
So then when you insert a user into the database, you could do something like this:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO `User` (UserName, Password)
  2. VALUES('username', SHA('password'))
  3.  
And to validate a user you could execute a query like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT UserID FROM `User` 
  2. WHERE UserName = 'username' AND Password = SHA('password');
  3.  
If that returns a single row, your user is valid. If it returns no rows your user is invalid.

Hope this helps you.
Sep 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
14
by: John Davis | last post by:
Anyone knows how to create the username/password authorization dialog in ASP? Thanks, John
7
by: jrefactors | last post by:
I want to ask how password is stored and how to check the authentication? I have heard password is never encrypted and decrypted, but it is hashed. For example, consider a simple email logon...
3
by: Henry | last post by:
Hi, my asp.net application is accessing a mssql on another server. This works fine when I use this in my web.config file: <add key="dbkey"...
8
by: Noel Volin | last post by:
Anyone who can help here is much appreciated. I am trying to programmatically log onto a website. I am using the code provided in VS for the AuthenticationManager Class example (...
2
by: Dmitri Priimak | last post by:
Hi All. There is one thing which somewhat annoys me, which is that psql always prompts me for a password. That makes it difficult for use in Makefile where I want to say 'make build_db', which...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
5
by: Afshar | last post by:
Hi everybody there, I have a special Login page that wants users to enter 3 passwords rather than a single password. But can't do it with Login control. I tried following scenarios: 1. Put an...
9
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.