I have a .php that registers a user by calling another php function but i dont know what the best way to redirect a user if the registration is successful. Is there an option other than header incase i want to echo something before i redirect?
<?
// processRegister.php
//////////////////////
// First include the class definition
include('UserClass.php');
// Next, create an instance of the class
$newUser = new User;
// Call the registerUser() method, passing in the required variables
$newUser->registerUser($userName, $userPassword);
// If it was an error, the class will kill the script, if not, it will reach this point
$newUser->displayUserInfo();
?>
You can use 4 methods, as you said using a header redirect:
Another is to use a session and to set some message you want to display and then display that message after you have redirected.
You can also use javascript:
in php:
The last method is to use a HTML redirect: