Hi,
I'm having problems with the way I redirect users, when users add an event or edit an event in my calendar.
I have it setup so my index page includes all the other pages within a div, by passing a variable to the index page, which is the name of the page to be included.
This works fine but my problem is when I add an event using a form, the form is sent to 'index.php?page=addeventaction' where I want to insert the details into the event table, and redirect them back to my default welcome page.
Obviously this wont work with the code I have below, which is my editaction page.
I keep getting this error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\index.php:3) in C:\Program Files\xampp\htdocs\addeventaction.php on line 46
Is this way possible?
If not is there any way I can use my index includes with redirects?
Thanks in advance.
<?php
/* connect to db */
$link_id = db_connect();
/* confirm form is posted */
if (isset($_REQUEST['send']))
{
/* set posted variables */
$title = $_POST['title'];
$description = $_POST['description'];
/* Check startdate is valid */
if (checkdate($_POST['startmonth'],$_POST['startday'],$_POST['startyear']) != NULL)
{
$startdate = $_POST['startyear']."-".$_POST['startmonth']."-".$_POST['startday'];
}
else
{
echo "startdate is not valid, please try again";
}
/* Check startdate is valid */
if (checkdate($_POST['endmonth'],$_POST['endday'],$_POST['endyear']) != NULL)
{
$enddate = $_POST['endyear']."-".$_POST['endmonth']."-".$_POST['endday'];
}
else
{
echo "enddate is not valid, please try again";
}
/* validate variables */
if(empty($title)) echo("Enter a title");
if(empty($description)) echo("Enter a description!");
$query = "INSERT INTO tblevent VALUES(NULL, '$startdate', '$enddate',
'$title', '$description', NULL)";
$result = mysql_query($query);
header('Location: http://localhost/index.php');
}
?>