PDA

View Full Version : Good way to make a Log in script?


Digger3000
04-03-2005, 08:48 PM
I've never had a website where people could log in before. Is this a good way to make a log in script? When people join they enter a password in a password field and then I add "md5($_POST['pass'])" to a MySQL database. Then when people go to log in, it checks to see if "md5($_POST['pass'])" is the same as "pass" in the database, and if it is, it then sets cookies.

Fou-Lu
04-03-2005, 09:31 PM
Use sessions instead of cookies, many users shut their cookies off. All they are good for IMO is to enable quick login features. To use sessions, simply add session_start() prior to any other browser output, and set them with:

session_start();

$_SESSION['username'] = $user;

for instance.

Digger3000
04-03-2005, 09:42 PM
Will that work if I want to do something like

echo "Hello ".$_SESSION['MemName'].".";

?

FearTheDuce
04-04-2005, 02:41 AM
That should work

Fou-Lu
04-04-2005, 10:15 AM
yes, sessions work much like cookies while accessing them, but setting them is a lot easier. My post above shows how to set, and even better, you don't need output buffering while using them (if there is already data sent). Sessions are superior in everyway to cookies IMO.

baktec
04-13-2005, 09:30 PM
Using session is the best idea. Cookies may not work. for me Most case its not working. I meant the cookies

rlemon
04-13-2005, 09:45 PM
There are lots of different ways to make login scripts.

The first thing you should do is select how the users will connect to the DB..

we can work up from there.

marek_mar
04-13-2005, 10:04 PM
I'd start wit sessions... without them any login script is useless.