Reputation: 299
I have a class that inserts users into a database, although I'm having a little trouble initialising header() re-direct. Here is my code
public function Register() {
$username = $_POST['username'];
$password = $_POST['password'];
$query = mysql_query("INSERT INTO users (username, password, admin) VALUES ('$username', '$password', '0')");
header('Location: /view_registered.php?register=success');
}
Is there a way I can put the header within a variable then once the method's complete adding users to the db then pass the header variable back to my index.php page?
kind regards
Upvotes: 3
Views: 6377
Reputation: 2619
Try adding a .
header('Location: ./view_registered.php?register=success');
If in a folder below
header('Location: ./../view_registered.php?register=success');
If in a folder above
header('Location: ./FOLDER_NAME_HERE/view_registered.php?register=success');
If in a different place altogether
header('Location: http://www.google.com');
Upvotes: 3
Reputation: 6718
What trouble? May be you need to use output buffering ( http://www.php.net/manual/en/ref.outcontrol.php )?
Upvotes: 0
Reputation: 8508
if($query)
header('Location: /view_registered.php?register=success');
Upvotes: 0