Forum Moderators: coopster
<? some php script commands to verify etc
?>
<HTML>
the page to be shown
</HTML>
It goes something along these lines...
if (isset [php.net]($_POST [php.net]['submit'])) {
if (verify_data()) { // data is valid
$sql = "your SQL statement here";
mysql_query($sql); // execute the query, in this case the db is MySQL
header [php.net]("Location: thank_you_for_registering.php?userID=" . $_POST['userID']);
exit [php.net];
} else {
// do something if the data is invalid!
}
}
I've shown an example where
verify_data()is a user-defined function [php.net] but you could edit your code right inside the
ifcontrol structure [php.net] if you prefer.
<?php //some code here
?>
<script language = "JavaScript">
parent.location = "my_next_page.php";
</script>
<?php //carry on with your php code here
?>
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.<html>
<?php
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: [example.com...]
?>
Resource:
PHP Manual: header() function [php.net]
Although your javascript solution may work, are you sure that your intended audience will allow javascript in their browser?