I’m working on online membership application form for my amateur club’s website. The goal is collect the data in HTML then pass it to PHP. In PHP will take the variables format them in an email and send that data to the membership committee for there review. The form contains text, radio, and select elements.
Some of the text variables are passing through but non or the radio or select elements.
Here is code for the php portion:
<?php
$to = '[email protected]';
$subject = 'SFARC Member application Test';
$from = '[email protected]';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Declare PHP variables from html input
$date = $_POST['date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$nick_name = $_POST['nick_name'];
$address = $_POST['home_address'];
$city_town = $_POST['city_town'];
$zip_code = $_POST['zip_code'];
$email = $_POST['email'];
$home_phone = $_POST['home_phone'];
$cel_phone = $_POST['cel_phone'];
$call_sign = $_POST['call_sign'];
$arrl_member = $_POST['arrl_member'];
$membership_type = $_POST['membership_type'];
$membership_length = $_POST['membership_length'];
$payment_method = $_POST['payment_method'];
$membership_dues = $_POST['membership_dues'];
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
// Generate application in a message
$message = "Date: " $date
"First Name: "$first_name
"Last Name: "$last_name
"Nick Name: "$nick_name
"Address: "$address
"City/Town: "$city_town
"Zip Code: "$zip_code
"Email: "$email
"Home Phone: "$home_phone
"Cel Phone: "$cel_phone
"Callsign: "$call_sign
"ARRL Member: "$arrl_member
"Membership Type: "$membership_type
"Membership Years: "$membership_length
"Payment Method: "$payment_method
"Membership Dues: "$membership_dues"\r\n";
// Sending email
if(@mail($to, $subject, $message, $headers )){
echo 'Your membership application has been successfully submitted.';
} else{
echo 'Unable to submit your membership application. Please try again.';
}
?>
Also is there any way I can format $message so all the variables do a linefeed and return so they are not all bunched in a single line.
Thanks in advance
HP Garcia
Edited by Benanamen. Added Code Tags