i’m rolling my own form processor [as the built-in ones don’t work for me]. the form is validated on one page [say] "form.php" and on submission the user is taken to [say] "thanks.php" where they are presented with a personalised thank-you using the data submitted in the form. the "thanks.php" also does the actual emailing of the form info. when doing this on a ’hand-written’ web page, i do it as follows:
<?php
//// php mail() function to email form info
}
?>
<!DOCTYPE ........ etc........>
<html>
page content with "thank you" message
</html>
however, i’m finding it hard to get this to work with modx:
if i create a snippit with the PHP mail() function and then include that snippet in the page template, it generates a PHP parse error [presumably modx doesn’t like a snippet being put before the "doctype" declaration?]
if i make a new template specific for that page and add the full PHP mail() function directly into the code for the template, i don’t get any error messages, but the code isn’t parsed as PHP, as i can see the PHP code if i view the source for the page.
if i put the PHPcode in an external file and include this with an "@EVAL" call, i just get the "@EVAL" line written directly into my page. again, it seems that modx doesn’t like to parse an "@EVAL" occurring before the "doctype".
is there anyway round this by using a different technique from within modx?
if there isn’t, i’ll just have to build my own page and add it to my site "assets" folder, but i’m worried this will turn into a major hassle, trying to get it to properly integrate with the rest of the site.
all i really want is to be able to include a chunk of PHP code in a page, before the "doctype" declaration and have modx leave it as it is and let the server take care of the rest