OK, thanks for that, its in place and appears to work.
Main Topics
Browse All TopicsHi,
Apology's if the answer to this is found on another post, not found it so far.
I am looking to implement a system which includes a login portal, for users (stored in db) to login using PHP sessions.
Below is the code that i have used, which works, but the security aspect is concerning me.
Could you let me know if this is a secure way to implement this, and if i can improve it in any way?
thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: cxrPosted on 2009-04-27 at 13:36:56ID: 24245438
You are not escaping the input. Change this:
'];
']; ername); e_string($ username);
));" for all failed logins to camouflage the fact that you update the user record in the db when the correct username is entered.
$username=$_POST['username
...into this:
$username=$_POST['username
if(get_magic_quotes_gpc())
$username=stripslashes($us
$username=mysql_real_escap
Make a function for this, this code should be excecuted for all user input that goes into a sql statement.
You have separate messages for bad username and bad password. Even if the message is the same, the extra statements executed for bad passwords might allow the hacker to identify valid user names by measuring the response time. I suggest you execute something like "usleep(rand(100000,200000