A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.
It's fast and free.
processing...Retrieve Sign In
Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.
processing...Welcome to Webmonkey
- edit articles
- add to the code library
- design and write a tutorial
- comment on any Webmonkey article
Sign In Information Sent
Create Simpler PHP Logins
/skill level/
/viewed/
EDITORS NOTE: This page is incomplete. The user-generated content in this page may need your help. It may contain errors, inappropriate links and methods have not not been verified to work.
Comments on the future of this page belong under the Discussion tab. Press Edit to modify this page to add and remove content or correct for grammar and/or code errors.
Introduction
Creating a log in script using PHP can be easier using the power of strcmp().
What you'll need
You'll need to have a database, or text file and know how to look up the password using the username. This is simply to create a faster, easier, more secure way of comparing the two strings using PHPs built in strcmp() or strcasecmp() functions.
Steps
After accessing your username/password combinations through MySQL, a text file or other methods you can easily compare the string values using strcmp().
if(strcmp($userpass,$passentered)){ //display secure content } else { //ask for username/password combo again }
This is a quick and easy method. If the two strings passed to the function are EXACTLY the same, then the returned value will be 0. If case sensitivity is not necessary then use strcasecmp($a,$b) - which works exactly the same way but ignores case sensitivity.
- This page was last modified 18:53, 1 December 2008.
/related_articles/
Special Offer For Webmonkey Users
WIRED magazine:
The first word on how technology is changing our world.
