Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP MYSQL header() location

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

like image 676
user863739 Avatar asked Jun 26 '26 03:06

user863739


1 Answers

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');
like image 179
Caimen Avatar answered Jun 27 '26 17:06

Caimen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!