<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 2/3/2014
//
	include ("check_session.php");
	
	$page_name = $_REQUEST['page_name'];
	$recipient = $_REQUEST['recipient'];
	
	if (!isset($page_name) || ($page_name == ""))	{
		echo "No page form selected.";
		exit;
	}
	
	$query = "SELECT page_name FROM form_recipients WHERE page_name='$page_name'";
	$result = $bwb_dbh->query($query);
	if ($result->rowCount() > 0)	
		$query = "UPDATE form_recipients SET recipient = :recipient WHERE page_name = :page_name";
	else
		$query = "INSERT INTO form_recipients SET page_name = :page_name, recipient = :recipient";
	$stmt = $bwb_dbh->prepare($query);
	$stmt->execute(array(':page_name' => $page_name, ':recipient' => $recipient));
	
	echo "Page name: $page_name, Recipient: $recipient";
?>