Skip to content Skip to sidebar Skip to footer

Go To Html Page From Php Function

I started PHP recently and I was wondering : I have a php file which only contains a function called sqlConnect(); which checks that the user isn't yet logged into the MySQL DB,

Solution 1:

ob_end_clean();
header("Location: example.com");
exit();

Put this at the end where you want the user to be redirected. Header() doesn't let you redirect after an output is given, but ob_end_clean() allows you to redirect after an output.

Solution 2:

You can use the header() function to redirect clients to another page.

<?php
    header('Location: <your page>');
    exit;
?>

Post a Comment for "Go To Html Page From Php Function"