tags:

views:

62

answers:

3

here is my code

if($register){
header("Location: http://mydomain.com/userarea");
exit();
}

that if user is registered successfully it is redirected to userarea but after registering it stay on signup page but if i refresh the page it is redirecting me to userarea but i want to redirect the user on signup automatically.....how can i solve this problem

A: 

try to save a session or cookie value when user login

and if this parameter set

redirect him

Haim Evgi
A: 

Do you echo or write anything before the redirection?

If you want to show something like "you have registered", do it on a userarea site and from register form, call something like "register.php"

register.php:

<?php
//process registration without any output //and then redirect
header(..);
exit;

And then it should work

Adam Kiss
nop, i am just setting the sessions for the user and than redirecting him....but it is failing..........
Web Worm
it could be number of things... if there is no message from php/apache, check if the url is right, if you have turned on php errors to E_ALL, if headers from server don't indicate something and then maybe apache's access.log/error.log
Adam Kiss
+1  A: 

If you don't receive any error messages instead of redirection, then perhaps it's because $register is false? It's even more likely as it seems that exit() doesn't get executed. Try checking it with assert(). Otherwise, it's possible that you've already flushed the output (sent it to the client) and the header wasn't sent.

Ignas R