$query=$db->exec("INSERT INTO pages (title) VALUES ('$title')");
//if something went wrong, show the failure template with the error message
if(!$query)
{
$smarty->assign("error",$db->lastErrorMsg());
}
else
{
$new_page_id=return_page_id($title);
header("Location: index.php?".$new_page_id);
}
}
}
//else if the user chose to create a new section
elseif($to_add=='section')
{
//if the user didn't choose a page to add the section to (can only happen if there's no page in the database), show the failure template with the error message
if(empty($_POST['page_to_add_section_to']))
{
$smarty->assign("error","There has to be a page in the wiki first!");
}
//else if there's a page in the database and therefore the user chose it
else
{
//get the value of this page to add the section to and perform a database query to find the id of this page, needed for the page_id field in the sections table