Quote from: cawiji at Mar 11, 2010, 03:42 PM
I wonder if anyone can help me with a form I have on my site. I moved it over to Modx but I’m not sure how to code it.
In MODx, you have to put the PHP code in a snippet. MODx will print whatever the snippet returns, so you have to do it something like this:
This goes on the form page:
This goes in the MailForm snippet:
<?php
//MailForm snippet code
$output = "";
if(isset($hasError)) { //If errors are found
$output = '<p class="error">Please fill in properly the fields below. Thanks</p>';
} else if(isset($emailSent) && $emailSent == true) { //If email is sent
$output .= '<p class="success"><strong>Successfully Sent!</strong></p>';
$output .= '<p class="success">Thank you <strong>' . $name . '</strong> for contacting me! Your email was successfully sent and we will get back to you as soon as possible.</p>';
}
return $output;
?>
If you’re looking for a simple contact form, you might check out the SPForm snippet. For more complicated forms, look at the eForm snippet.