Okay. I’ve set all the templates to allow PHP and the parse order to input (just till I can get this sorted out).
Here’s the code for the survey page.
{embed="main/header_inc" survey="true"}
<form action="/index.php?/main/survey_complete/" method="POST">
<!-- Snip Input boxes, submit button -->
</form>
{embed="main/footer_inc"}
And here’s the ‘action’ survey_complete page.
<?PHP
if (isset($_REQUEST['action']))
$action = $_REQUEST['action'];
else
$action = "";
if ($action == "surveyFilled"){
//Test for dupe emails
$result = array();
/*Snip, standard PHP MySQL query stuff -- output to array: $result */
if (count($result) > 0){
?>{embed="main/header_inc"}<?PHP
echo "<h2>Whoops!</h2> That email has already been used in this survey. You may not enter twice.";
?>{embed="main/footer_inc"}<?PHP
die; //Halt the script here.
}
/*SNIP -- More PHP validation of inputs, attempt to INSERT into Mysql --*/
$mysqlError = mysql_error();
if ($mysqlError == ""){ // No errors, go ahead and display the thank you page
?>{embed="main/survey_thanks" survey="true"}<?PHP
}else{ // There seems to have been a MySQL Error. Notify the user that there was a problem.
?>{embed="main/header_inc" survey="true"}<?PHP
echo "<!-- ".$mysqlError."-->";
echo "<h2>Whoops!</h2> There was an error processing your request. Please try again later.";
?>{embed="main/footer_inc"}<?PHP
}
?>
The survey_complete page has it’s own (different) header and footer.
I originally had both on the same page, but in an attempt to correct my problem I made the survey_complete page a seperate template.
Edit—it works fine if it gets to embed the survey_thanks page, but if I try with a dupe email the output I get is:
{embed="main/header_inc"}<h2>Whoops!</h2> That email has already been used in this survey. You may not enter twice.{embed="main/footer_inc"}
I have one of those feelings that it’s something stupidly small I’m overlooking, and I’m going to look like a fool for having had to post to the support forms for this 