<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 9/9/2008
// Revised: 2/10/2012	ELL
// Added table prefix handling.
	
	include ("check_session.php");

	$title = $_REQUEST['title'];
	$title = str_replace("'", "&#39;", $title);
	$page_name = $_REQUEST['page_name'];


	$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "page_titles` WHERE `page_name` = '" . $page_name . "'";
	$result = $bwb_dbh->query($query);
	if ($result->fetch(PDO::FETCH_ASSOC))
		$query = "UPDATE " . BWB_TABLE_PREFIX . "page_titles SET `title`='$title' WHERE `page_name`='$page_name'";
	else
		$query = "INSERT INTO " . BWB_TABLE_PREFIX . "page_titles (`page_name`, `title`) VALUES ('$page_name', '$title')";
	$cnt = $bwb_dbh->exec($query);
	
	if ($page_name == "_default_")
		header("Location: edit_title_select.php?page_title_saved=1");
	else
		header("Location: edit_title_select.php?selected_page_name=$page_name&page_title_saved=1");
?>
