So I have a form with action insert.php
My insert.php looks like this
<?php
$con = mysql_connect("localhost","database_user","password","database");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("watchdl1_database", $con);
$sql="INSERT INTO nametable (firstname, lastname)
VALUES
('$_POST[firstname]','$_POST[lastname]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
</body>
</html>
How can I get the user to be redirected to a url after the html form submits to the database using this php code?
Thanks.
EDIT: I get this error Parse error: syntax error, unexpected 'header' (T_STRING) in insert.php
when ever I try to add header command.
php
header('Location: example.php');
javascript
window.location="example.php";