Hi,
I thought this would be easy to find, but it seems like it isn't. I have a form in php where someone can input info, it is checked to see that something is there and then it is put into a mySQL database. How to I get it to redirect the user to a new page after I put the into into the database? Here is some code:
<?php
if (isset($_POST["seen"]))
{
$error = 0;
if ($_POST["timeplay"] == "")
{
echo "Please fill in date / time";
$error += 1;
}
else
{
$timeplay = strtotime($_POST["timeplay"]);
$timeplay = date ("m/d/y h:i A", $timeplay);
}
if ($error != 0)
{
?>
<FORM METHOD ="POST" ACTION ="time_play.php">
A date and time:
<INPUT NAME="timeplay" TYPE="TEXT" value="<? echo $_POST['timeplay'] ?>">
<INPUT NAME="seen" TYPE="HIDDEN">
<INPUT NAME="submit" TYPE="SUBMIT" value="Submit">
</form>
<?
}
else
{
include "conn.inc.php";
session_start();
$query = "INSERT INTO play (time) VALUES ('$timeplay')";
$result = mysql_query($query)
or die (mysql_error());
// Redirect needed here
}
}
else
{
?>
<FORM METHOD ="POST" ACTION ="time_play.php">
A date and time:
<INPUT NAME="timeplay" TYPE="TEXT">
<INPUT NAME="seen" TYPE="HIDDEN">
<INPUT NAME="submit" TYPE="SUBMIT" value="Submit">
</form>
<?
}
?>
I've found info on the use of a header, but it all says that the header must go at the top of the file. Is there a way to do it not at the top of the file?
thanks!
Hailey