I need to redirect to another site after storing form data to a mysql table. I read that there's no possible output that can proceed the use of a header statement. Does this include my sql-related code? What exactly does 'output' refer to?
TIA,
David
redirect after SQL
Moderator: General Moderators
Re: redirect after SQL
Output is anything that is sent to the user's browser. Including blank spaces. As long as you don't call header(); after anything is output to the user's browser, you won't have any problem.
Your SQL code should not cause any output to occur.
For example:
The above will work.
Below will not work.
Your SQL code should not cause any output to occur.
For example:
Code: Select all
<?php
$q = "SELECT * FROM table";
mysqli_query($dbc, $q);
header('Location: /thanks.php');
?>Below will not work.
Code: Select all
<html>
<?php
$q = "SELECT * FROM table";
mysqli_query($dbc, $q);
header('Location: /thanks.php');
?>