tags:

views:

39

answers:

2

Hi, I want to log in the user after he registrered.

So, you login in a form with POST method. Now i was thinking about doing it this way:

header("index.php?doLogin=Login&user_email=$usr_email&pass=$data[pwd]");

But then, when you login its POST and not GET,

// Log in
if (isset($_POST['doLogin']) && $_POST['doLogin'] == 'Login')...

So what do I do? Another idea doing this maybe?

+3  A: 

When user logging in you check the user credentials against DB then save state to session, right?

Just do that after user register, no need to send user to some page. Just do it on the same file, the registration takes place.

leonardys
Yes i could duplicate what i have inside doLogin and put after the reg, but i was maybe thinking smart and simple way.. is this more recommended?
Karem
It's a much better solution then redirecting, sending a password via get could be a security problem, because the password get's logged in the browsers history.
jigfox
@Karem: you don't need to duplicate the code inside of doLogin, just take the login code and put it in a function and call it from different points of your code, that is what functions are for. To not duplicate some task, instead define it once and use it multiple times.
jigfox
made a function for it now, and runs that, nice and easy thanks
Karem
A: 

Its not really good to send the password over the URL. Send it over POST. Do you set a SESSION variable in your Login functions?

When you set the SESSION variable its easier to set the same variable direct after the registration and then redirect to the index.php.

Stony