articlehaul.com articlehaul.com
Search:    Index Page :> About Us :> Privacy of Info :> Terms of Use :> Add Your Link :> Submit Article   
Add Your Link
 

Self Help

Healthcare & Medicine

Education & Learning

Travel & Accommodation

Online Shopping

Adventure & Sports

Drink & Food

Research & Science

Finance & Investment

Careers & Employment

News & Media

Relationship & Lifestyle

Health & Hygiene

Family & Home

Recreation & Entertainment

Vehicles & Automotive

Art & Culture

Computers & Networking

Politics & Government

Property & Estate

Teens & Kids

Indoor Games

People & Communities

Companies & Business


 

Index Page –› Computers & Networking –› Web Development Services
 

Things To Take Note When Writing PHP Login Scripts

 

Almost every website nowsadays will have some sort of a login system. If you decide to write a login script yourself in PHP, this article will provide some important pointers on the security of the script you are writing. This article will talk on a common login hacking technique known as The SQL Injection Attack. This is not new in the programmer's world but worth taking note especially when you are new to programming.There are hackers everywhere, so beware!

When the user submits a form consisting of the username and password, all the variables will be store in the $_POST array after submitting. You can get the values of the array easily using:

$usr = $_POST['username']; $pwd = $_POST['password'];

Where "username" and "password" are the names of the textfields in your form.

How do you deal with these values? You probably verify it against your database. If the username and password matches at least one record in the database, you will let this user proceed on to the secure area, else you will probably throw an error, prompting the user to re-login. During the verification process, your SQL statement might look like this:

SELECT * FROM `user_table` where username='$usr' AND password='$pwd'

Re-looking at the SQL statement, if someone leaves username empty and writes " ' OR username LIKE '%" in the password field, then your whole SQL statement becomes:

SELECT * FROM `user_table` where username=' ' AND password=' ' OR username LIKE ' % '

This statement means selecting all the records in the table. If your criteria of letting the user proceed is that the return number of records is more than 0 (at least one user found), then this SQL statement will return all records, meaning that the user will be able to slip pass through the verification process. This type of hacking is famously known as The SQL injection attacks.

One good way to prevent this from happening is to make sure the $_POST array is safe from escape strings such as ' and ". You can filter your $_POST array using

$usr = mysql_real_escape_string($_POST['username']);
$pwd = mysql_real_escape_string($_POST['password']);

There are of course other ways to do it but the idea is to let you know that you have to be very careful in handling the data retrieved from forms, epecially more so for usernames and passwords.

Author: Bernard Peh
 
Author Bio:

Bernard Peh

Bernard Peh is a great passioner of web technologies and one of the co-founders of Sitecritic.net Site Reviews. He works with experienced web designers and developers for more than 5 years, developing and designing commercial and non-commercial websites. During his free time, he does website reviews, freelance SEO and PHP work.

This article can be searched using: web site development, web design & development, website development tampa
 
 
 

Related Articles

 
Two Easy Ways To Fix PC Bugs
 
A Beginners' Guide to Email Blacklists
 
Why Start An Affiliate Program?
 
What to Look for in a Video Card
 
3 Quick Ideas to Boost Website Traffic and Broaden Your Audience
 
UAV Swarm Reconfiguration for computer war games
 
What Every Prospective Website Owner Must Know
 
7 Web Site Mistakes that Cause Your Visitors to Leave Empty-Handed
 
Reselling Domain Names
 
Pallet Rack Ordering Online
 
 
 
 
 

Desktop Security Software Risks - Part 2

This is the third in a series of articles highlighting reasons why we need a new model for anti-viru ... - Tim Klemmer
 

3 Quick Ideas to Boost Website Traffic and Broaden Your Audience

No matter what you're marketing on the web, there are days that it seems like your traffic numbers a ... - Melissa Brewer
 

Adware Explained

Very few people want to pay money for small pieces of software. However useful it might be, if it's ... - John Gibb
 
 

Ebooks -- Self-Publishing Your Way to Internet Success: Part 3 Ebook Formats (HTML)

In part 2 of this series, we focused on ebooks formatted in PDF. We will now continue with HTML comp ... - Shelley Lowery
 

Is Branding a Legitimate Internet Marketing Strategy

Internet marketing is all about hard results, not generic concepts of branding. Still, there are way ... - Halstatt Pires
 
 
Index Page :> Privacy of Info :> Terms of Use
© 2006 www.articlehaul.com - All Rights Reserved Worldwide