I’m new to modX. I have a form in which I want the data put into an email format and sent to the site owner. I had it all working outside of modx. How do i get it working in modx? Perhaps someone could point me in the right direction for some simple documentation?
The form code:
notice the action is: ?action=entertowin
<div id="content_text">
<span class="home_title">Enter to Win</span>
<?php
if (isset($_SESSION[’success’])) {
echo "<font color=\"red\"><b>". $_SESSION[’success’] . "</b></font>
";
unset($_SESSION[’success’]);
}
?>
<h3>YOUR CAUSE CONNECTION</h3>
<h3>MONTHLY DRAWING REGISTRATION</h3>
We want to know your passion!
Each month we will give away a $25.00 gift certificate. Entering is Simple! All you have to do is tell us about a cause that is important to you. You are welcome to register up to 5 times each month with a unique cause for each entry.
Important Note: You do not have to be actively involved in the cause to register….. just passionate about it!
<form name="form1" id="form1" action="?action=entertowin" method="post">
<font color="red">*</font>Name
<input type="text" name="name">
<font color="red">*</font>Contact Number
<input type="text" name="phone">
<font color="red">*</font>Email Address
<input type="text" name="email" size="40">
<font color="red">*</font>Tell us about a cause that is important to you?
<textarea cols="40" rows="7" name="comments"></textarea>
<font color="red">*</font>Are you actively involved with this cause?
<select name="involved"><option value="YES" selected>Yes</option><option value="NO">No</option></select>
Does your cause of have a website? Enter it if applicable.
<input type="text" name="website">
<input type="submit" name="entertowinnow" value="Submit" onclick="return entertowin(’form1’, this.name);">
</form>
</div>
PHP code:
<?php
case "entertowin":
$email_address = "
[email protected]";
$name = $_POST[’name’];
$subject = "Contest Signup";
$mail_body = "NAME: {$_POST[’name’]}\n\n";
$mail_body .= "PHONE: {$_POST[’phone’]}\n\n";
$mail_body .= "EMAIL: {$_POST[’email’]}\n\n";
$mail_body .= "What is important to you about this cause?: {$_POST[’comments’]}\n\n";
$mail_body .= "ARE YOU INVOLVED: {$_POST[’involved’]}\n\n";
$mail_body .= "WEBSITE: {$_POST[’website’]}\n\n";
Sendmail script
$try = mail($email_address, $subject, $mail_body, "From: $name \nX-Mailer: PHP/" . phpversion());
if (!$try) {
$_SESSION[’success’]="";
} else {
$_SESSION[’success’]="Thank you for your submission. You’ve been entered into the contest. We will notify you if you win the monthly drawing.";
}
break;
?>