I have a problem with the script below. When a form is filled in this script handles the input. It insert data into the database. But the problem is that the user is not redirect to the form page. It displays that the data has been inserted.
I try to redirect the user with the header(); function. But it doesn't work.
This is the script
<?php
//maakt variabelen uit formulier toegankelijk
$voornaam = $POST['voornaam'];
$achternaam = $POST['achternaam'];
//database verbinding
$db = mysql_connect("localhost","root","root")
or die("Could not connect : ". mysql_error());
// query uitvoeren
mysql_select_db("database_name", $db);
$query = "insert into test (Voornaam,Achternaam) values('$voornaam', '$achternaam')";
$result = mysql_query ($query,$db)
or die ("Query failed : ". mysql_error());
echo "<span style=\"position:absolute; top:200; left:200\">Thank you, information entered!<br />";
// redirect naar een andere pagina
print "Click <a href=\"http:/localhost/data1.php\">here</a> to go back to the page
</span>";
//This should redirect the user
header ("location: data1.php");
mysql_free_result($result); // free resultset
mysql_close($db); //close //close connection
?>
Does anyone have some comments?
Thanks, Jonathan