I'll preface this by saying I'm not a php wizard.
I had a custom php script that worked literally for years with any form. It emailed all the information on about 6 different forms on 3 separate websites to 6 different email addresses, but all hosted on GoDaddy. I've changed absolutely nothing on the forms or the scripts and in the last week it has just stopped emailing the form. It will still redirect the user to the next page when they hit submit, but on our end we get nothing at all. This is true for all 6 forms on all websites and to all email addresses. I contacted GoDaddy and they basically said they probably made a change to their php settings or rules, but couldn't tell me what the change was or what is wrong with my script. This has had a huge impact on one site in particular, as we collect membership dues and have had several people who's payments have come through but no accompanying info.
So knowing that I was very unlikely to ever figure out what was wrong with the custom script (which I didn't write), I decided that fine, I'll just create new php scripts for each form even though it's a pita. Basically I just need it to work. But not being awesome at PHP, my script seems to be flawed. The email now goes through but the fields that are filled out do not translate. So my email looks like this:
Event:
Renewal:
Need New Card:
Membership Number:
Name:
Facebook Name:
Spouse Name:
Spouse Facebook Name:
Children Info:
Email:
Phone:
Address:
How Did You Hear About Us:
PP Account Name:
EMT Account Name:
EMT Password:
Contact Volunteer:
Understand Membership Terms:
Comments:
End of message
Which is slightly better than no email at all but not helpful since the entered fields are not populating. I'm pretty sure it's a PEBKAC (problem exists between keyboard and chair) error and I'm hoping someone can help me fix it before I rip my hair out. I like my hair.
The form:
<form onsubmit="return validate();" method="post" name="membership_form"
action=http://www.apvillage.ca/contact.php><!--
<input name="event" size="30" type="hidden" value="Membership" />
--><label>Membership: <select name="Event"> <option selected value=oneyear>One Year Membership with APVCS</option></select></label>
<div class="radio_checkbox padded">
<input value="Yes" type="checkbox" name="Membership_renewal"> I am renewing an existing membership <input value="Yes" type="checkbox" name="Need_new_card"> I need a new card </div> <label> Membership Number: <input size="30" name="Membership_number"></label>
<label> </label> <label class="highlight">Legal Name: <input size="30" name="Legal_name"> </label>
<label>Name that appears on Facebook (leave blank if the same): <input size="30" name="Facebook_name"> </label>
<label class="highlight"> Spouse's Name (to be included in membership): <input size="30" name="Spouse_legal_name"> </label>
<label> Spouse's Facebook Name (leave blank if the same): <input size="30" name="Spouse_facebook_name"></label>
<label class="highlight"> Child(ren)'s First Names and Birth Year: <input size="30" name="Childrens_names"> </label>
<label> Preferred Email: <input size="30" name="email"></label>
<label> Preferred Phone (please specify if land or cell): <input size="30" name="phone"></label>
<label class="highlight">Full
Mailing Address, including City and Postal: <textarea rows="4" cols="26" name="address"></textarea> </label>
<label>How did you hear about us?<input size="30" name="How_did_you_hear_about_us"> </label> <b> Please select your payment method: </b> <br>
<div class="radio_checkbox highlight padded"><input value="Yes" type="checkbox"
name=Paypal[]> Paypal (you do not need a pp account to pay by credit card with them) </div>
<label> Name Or Company associated with your PP account if applicable <input size="30" name="Paypal_account_name"> </label>
<div class="radio_checkbox highlight padded"><input value="Yes" type="checkbox"
name=EMT[]> Email Money Transfer (to memberships@apvillage.ca) </div>
<label> Name and email EMT will come from <input size="30" name="Emt_account_name"> </label>
<label> Password answer for EMT <input size="30" name="Emt_password"></label> <!--<div class="radio_checkbox highlight padded">
Radio Buttons:<br />
<label>yes <input name="radio_buttons" value="yes" type="radio" /></label>
<label>no <input name="radio_buttons" value="no" type="radio" /></label> </div>
<div class="radio_checkbox padded">
Check Boxes:<br /> --><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><!--
<label>yes <input name="checkboxes[]" value="yes" type="checkbox" /></label>
<label>no <input name="checkboxes[]" value="no" type="checkbox" /></label> </div>
<label class="highlight">-->
<div class="radio_checkbox padded">
<input value="Yes" type="checkbox" name="Contact_volunteer"> I can be contacted about volunteer opportunities </div>
<div class="radio_checkbox padded"><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute -->
<input value="Yes" type="checkbox" name="Understand_membership_terms"> I understand how <a
href="#member" target=_blank> membership </a> works, and the expiration period (required for membership)</div>
<label class="highlight">Questions/Comments: <textarea rows="4" cols="26" name="comments"></textarea> </label>
<div class="submit"><input value="submit" type="submit" name="submit_button">
</div></form>
The php
<?php
$event = $_REQUEST['event'] ;
$Membership_renewal = $_REQUEST['Membership_renewal'] ;
$Need_new_card = $_REQUEST['Need_new_card'] ;
$Membership_number = $_REQUEST['Membership_number'] ;
$Legal_name = $_REQUEST['Legal_name'] ;
$Facebook_name = $_REQUEST['Facebook_name'] ;
$Spouse_legal_name = $_REQUEST['Spouse_legal_name'] ;
$Spouse_facebook_name = $_REQUEST['Spouse_facebook_name'] ;
$Childrens_names = $_REQUEST['Childrens_names'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$address = $_REQUEST['address'] ;
$How_did_you_hear_about_us = $_REQUEST['How_did_you_hear_about_us'] ;
$Paypal[] = $_REQUEST['paypal'] ;
$Paypal_account_name = $_REQUEST['Paypal_account_name'] ;
$EMT[] = $_REQUEST['emt']
$Emt_account_name = $_REQUEST['Emt_account_name'] ;
$Emt_password = $_REQUEST['Emt_password'] ;
$Contact_volunteer = $_REQUEST['Contact_volunteerr'] ;
$Understand_membership_terms = $_REQUEST['Understand_membership_terms'] ;
$comments = $_REQUEST['comments'] ;
/* Let's prepare the message for the e-mail */
$message = "
Event: $event
Renewal: $Membership_renewal
Need New Card: $Need_new_card
Membership Number: $Membership_number
Name: $Legal_name
Facebook Name: $Facebook_name
Spouse Name: $Spouse_legal_name
Spouse Facebook Name: $Spouse_facebook_name
Children Info: $Childrens_names
Email: $email
Phone: $phone
Address: $address
How Did You Hear About Us: $How_did_you_hear_about_us
PP Account Name: $Paypal_account_name
EMT Account Name: $Emt_account_name
EMT Password: $Emt_password
Contact Volunteer: $Contact_volunteer
Understand Membership Terms: $Understand_membership_terms
Comments: $comments
End of message
";
mail( "memberships@apvillage.ca", "Membership Form",
$message, "From: memberships@apvillage.ca" );
header( "Location: http://www.apvillage.ca/form_response.htm" );
?>
And just in case anyone in this world can identify for me why my old script just stopped working, here it is:
<?php
function filter($input){
$to_remove = array('~','`','{','}','^','[',']','<script>','</script>','<applet>','</applet>');
$clean = trim(str_replace($to_remove, "-", $input));
return $clean;
}
function cleanup_text_for_display($txt){
$txt = str_replace('_',' ',$txt);
$txt = ucwords($txt);
//$txt = str_replace(' ',' ',$txt);
return $txt;
}
if(isset($_POST) && !empty($_POST)){
$mail_content = "MEMBERSHIP FORM\r\n";
$mail_content .= "-------------------------------\r\n";
date_default_timezone_set('MST');
$mail_content .= date('F j, Y, g:i a')."\r\n";
$html_content = '<h2>Thank you for your payment</h2>';
$html_content .= '<p>If there are any errors in the information below <a href="mailto:marketing@apvillage.ca">please let us know</a>.</p>';
foreach($_POST as $key => $value){
if(is_array($value)){
$mail_content .= cleanup_text_for_display($key).': ';
foreach($value as $item){
$mail_content .= $item." ";
}
$mail_content .= "\r\n";
}else{
if($key == 'submit_button')
continue;
// build email content
$mail_content .= cleanup_text_for_display($key).': '.$value."\r\n";
// layout form data for display in web page
$html_content .= '<p>'.cleanup_text_for_display($key).': '.$value.'</p>';
}
}
}
//,"From:memberships@apvillage.ca\r\nReply-to:memberships@apvillage.ca"
if(!mail(
//'memberships@apvillage.ca,
'memberships@apvillage.ca',
'Membership Form',
$mail_content
))
$html_content = '<h3>ERROR: Sorry, this message could not be sent.</h3>';
$html_content .= 'Please try resubmitting the form.<br /><a href="http://www.apvillage.ca"><< BACK </a>';
$html_content .= '<br /><br />If this problem persists, please <a href="mailto:marketing@apvillage.ca">let us know</a>. Thanks.';
}
else {
header("location:http://www.apvillage.ca/form_response.htm");
}
?>