I am trying to add new items to a legacy sendeail.php form. However, when I add the new items to the php listing and the mail delivery, they aren't displaying at all in the email that is sent. At least the emails are going through... I know that I need to refine the radio and check box items, but NONE of the new items are showing. New items are all items after $attn in the code list immediately below. Any and all help is appreciated, thank you very much!
My PHP code is:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$phone = $_POST['phone'];
$interest = $_POST['interest'];
$budget = $_POST['budget'];
$budget = $_POST['day'];
$timeslot = $_POST['timeslot'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"#") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Please complete all the fields.</h2>\n";
echo $badinput;
die ("Use the Back button on your browser...");
}
if(empty($visitor) || empty($visitormail) || empty($notes ) || empty($attn ) || empty($phone )) {
echo "<h2>Please click Back and fill in all fields.</h2>\n";
die ("Use the Back button on your browser... ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Web Site Request About: $attn \n
From: $visitor ($visitormail)\n
Phone: $phone \n
Message: $notes \n
Interested In: $interest \n
Heating Budget: $budget \n
Time Availability: Days - $day \n
Time Availability: Morning or Afternoon - $timeslot \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
mail("XXXXX", $subject, $message, $from);
?>
And my HTML code is:
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
All fields are required.</p>
<p align="left">Your Name:
<input type="text" name="visitor" size="35" />
</p>
<p align="left">
Your Email:
<input type="text" name="visitormail" size="35" />
</p>
<p align="left">
<label for="Phone">Your Phone: </label>
<input type="text" name="Phone" id="Phone" size="35"/>
</span></p>
<p align="left">
About:
<select name="attn" size="1">
select name="interest" id="interest">
<option value="General Query">General question</option>
<option value="Plumbing Query">Plumbing</option>
<option value="Gasfitting Query">Gasfitting</option>
<option value="Central Heating Query">Central Heating</option>
<option value="Custom Work Query">Several options</option>
</select>
<br />
<p align="left">Your Home Heating Budget:
<select name="attn2" size="1">
select name="budget" id="budget">
<option value="Under 10000">$8000 to $10,0000</option>
<option value="10 to 12 Thousand">$10,000 to $12,000</option>
<option value="12 to 15 Thousand">$12,000 to $15,000</option>
<option value="+15000 Plus">$15,000 +</option>
</select>
<br />
<p align="left">Are you considering other forms of heating?
<input type="checkbox" name="Yes-OtherFormsHeating" id="Yes-OtherFormsHeating" />
<label for="Yes">Yes</label>
<input type="checkbox" name="No-OtherFormsHeating" id="No-OtherFormsHeating" />
<label for="No">No</label>
<br />
</p>
<p align="left">Please give us a few details about your home and requirements: <br />
<textarea name="notes" rows="6" cols="70"></textarea>
</p>
<p align="left">To give you a quote for gas central heating, we need to visit your home. What is a good day and time for us to come to you? Choose one option.</p>
<p align="left">
<input type="radio" name="day" id="day_M" value="M" />
<label for="M">M</label>
<input type="radio" name="day" id="day_T" value="T" />
<label for="T">T</label>
<input type="radio" name="day" id="day-W" value="W" />
<label for="W">W</label>
<input type="radio" name="day" id="day_Th" value="Th" />
<label for="Th">Th</label>
<input type="radio" name="day" id="day_F" value="F" />
<label for="F">F</label>
</p>
<p align="left">When is a good time on this day for us to come to you? Choose one or both.</p>
<p align="left">
<input type="checkbox" name="timeslot" id="8:30-12:30AM" />
<label for="8:30-12:30AM">8:30 - 12:30</label>
<input type="checkbox" name="timeslot" id="12:30-4" />
<label for="12:30-4">12:30 - 4:00</label>
</p>
First of all: always validate input (POST). You've got some basic validation already but read up on the security implications regarding POST data.
Array keys in php are case sensitive. $_POST['phone'] is not the same as $_POST['Phone'].
Your select tags are broken, take a look at the colouring in your posted html.
You have declared $budget twice, overwriting the intended data:
$budget = $_POST['budget'];
$budget = $_POST['day'];
checkboxes should be arrays when posted, change the name attribute to thename[] instead of just thename. Of course your php script must handle the resulting array after this change.
Related
I want to send a form that have checkboxes in it, it was working fine but I do not what I did that now I received an error everytime I send it. I think the problem has to do with the checkboxes because I recall that I had problems with them in the past. I am working with a single file in PHP.
This is the code for the form:
<div class="contactFrm">
<?php if(!empty($statusMsg)){ ?>
<p class="statusMsg <?php echo !empty($msgClass)?$msgClass:''; ?>"><?php echo $statusMsg; ?></p>
<?php } ?>
<form action="" method="post">
<h6>Contact Information</h6>
<fieldset id="left">
<h4>First Name</h4>
<input type="text" name="name" required>
<h4>Company Name</h4>
<input type="text" name="compname" required>
<h4>Phone Number</h4>
<input type="text" name="phone" required>
<h4>Date of Arrival</h4>
<input type="date" name="ardate" required>
</fieldset>
<fieldset id="right">
<h4>Last Name</h4>
<input type="text" name="lname" required>
<h4>Website URL</h4>
<input type="text" name="website" required>
<h4>Email</h4>
<input type="email" name="email" required>
<h4>Date of Departure</h4>
<input type="date" name="depdate" required>
</fieldset>
<h4>What is your estimated time of arrival?</h4>
<input type="text" name="estimated_time" required>
<h4>How many groups will you be hosting?</h4>
<textarea name="groups" required> </textarea>
<h4>How many participants per group do you need to accommodate?</h4>
<input type="text" name="mparticipants" required>
<h4>What are the date/time scheduled for each group?</h4>
<textarea name="scheduled" required> </textarea>
<h4>What kind of set-up will you like?</h4>
<p>Additional fees may apply for living room/specialty set-ups.</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup1[]" value="living_room" id="CheckboxGroup1_0">
Living Room</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup1[]" value="conference_room" id="CheckboxGroup1_1">
Conference Room</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup1[]" value="other" id="CheckboxGroup1_2">
Other (please specify at the end of the form)</label>
<br>
</div></p>
<h6>Clients</h6>
<h4>How many individuals/clients from your company will be attending?</h4>
<p>These individuals will be stationed in the client room.</p>
<input type="text" name="attending">
<h6>Services</h6>
<h4>Which technology services are you interested in?</h4>
<p>Check all that apply (All of these services are charged separately. Some will involve additional costs from the estimate provided to you.)</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="sd_dvd" id="CheckboxGroup2_0">
Stationary SD DVD Recording</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="hd_video" id="CheckboxGroup2_1">
Stationary HD Video Recording</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="streaming" id="CheckboxGroup2_2">
High Definition Video Streaming (Focus Vision (SD) streaming is also available)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="smartboard" id="CheckboxGroup2_3">
Smartboard (also functions as TV/DVD/PC)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="translation" id="CheckboxGroup2_4">
Translation Equipment</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="videographer" id="CheckboxGroup2_5">
Videographer Assisted Recording (SD/HD)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup2[]" value="other" id="CheckboxGroup2_6">
Other (please specify on notes section)</label>
<br>
</div></p>
<h4>Will you need meal(s) to be provided?</h4>
<p>You will be able to pick from various menus once the booking is confirmed.</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="participants" id="CheckboxGroup3_0">
Yes, for Participants</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="clients" id="CheckboxGroup3_1">
Yes, for Clients</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="breakfast" id="CheckboxGroup3_2">
Breakfast</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="lunch" id="CheckboxGroup3_3">
Lunch</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="dinner" id="CheckboxGroup3_4">
Dinner</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="snacks" id="CheckboxGroup3_5">
Snacks</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup3[]" value="beverages" id="CheckboxGroup3_6">
Beverages</label>
<br>
</div></p>
<h4>Do you need research service(s)?</h4>
<p>Check all that apply.</p>
<p><div class="inline-field">
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="moderator" id="CheckboxGroup4_0">
Moderator(s)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="recruiting" id="CheckboxGroup4_1">
Recruiting</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="reporting" id="CheckboxGroup4_2">
Reporting and Analysis</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="quantitative" id="CheckboxGroup4_3">
Quantitative</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="other" id="CheckboxGroup4_4">
Other Research Services (please specify in the notes section)</label>
<br>
<label>
<input type="checkbox" name="CheckboxGroup4[]" value="na" id="CheckboxGroup4_5">
N/A</label>
<br>
</div></p>
<h6>Additional Information</h6>
<h4>Please include any additional information or document that would help us facilitate your request.</h4>
<textarea name="additionalinfo"> </textarea>
<h4>Document Upload</h4>
<input type="file">
<input type="submit" name="submit" value="Submit">
<div class="clear"> </div>
</form>
and this is the PHP:
<?php
$statusMsg = '';
$msgClass = '';
if(isset($_POST['submit'])){
// Get the submitted form data
$name = $_POST['name'];
$lname = $_POST['lname'];
$compname = $_POST['compname'];
$phone = $_POST['phone'];
$ardate = $_POST['ardate'];
$website = $_POST['website'];
$email = $_POST['email'];
$depdate = $_POST['depdate'];
$estimated_time = $_POST['estimated_time'];
$groups = $_POST['groups'];
$mparticipants = $_POST['mparticipants'];
$scheduled = $_POST['scheduled'];
$additionalinfo = $_POST['additionalinfo'];
$attending = $_POST['attending'];
$CheckboxGroup1 = (implode("," , $_POST['CheckboxGroup1']));
$CheckboxGroup2 = (implode("," , $_POST['CheckboxGroup2']));
$CheckboxGroup3 = (implode("," , $_POST['CheckboxGroup3']));
$CheckboxGroup4 = (implode("," , $_POST['CheckboxGroup4']));
// Check whether submitted data is not empty
if(!empty($name) && !empty($lname) && !empty($compname) && !empty($phone) && !empty($ardate) && !empty($website) && !empty($email) && !empty($depdate) && !empty($estimated_time) && !empty($groups) && !empty($mparticipants) && !empty($scheduled) && isset($CheckboxGroup1) && isset($CheckboxGroup2) && isset($CheckboxGroup3) && isset($CheckboxGroup4) && !empty($attending) && !empty($additionalinfo)){
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
$statusMsg = 'Please enter your valid email.';
$msgClass = 'errordiv';
}else{
// Recipient email
$toEmail = 'osek2112#gmail.com';
$emailSubject = 'Facility Request Submitted by '.$name;
$htmlContent = '<h2>Facility Request Form</h2>
<h4>Name</h4><p>'.$name.'</p>
<h4>Last Name</h4><p>'.$lname.'</p>
<h4>Company Name</h4><p>'.$compname.'</p>
<h4>Phone Number</h4><p>'.$phone.'</p>
<h4>Date of Arrival</h4><p>'.$ardate.'</p>
<h4>Website URL</h4><p>'.$website.'</p>
<h4>Email</h4><p>'.$email.'</p>
<h4>Date of Departure</h4><p>'.$depdate.'</p>
<h4>What is your estimated time of arrival?</h4><p>'.$estimated_time.'</p>
<h4>How many groups will you be hosting?</h4><p>'.$groups.'</p>
<h4>How many participants per group do you need to accommodate?</h4><p>'.$mparticipants.'</p>
<h4>What are the date/time scheduled for each group?</h4><p>'.$scheduled.'</p>
<h4>What kind of set-up will you like?</h4><p>'.$CheckboxGroup1.'</p>
<h4>Which technology services are you interested in?</h4><p>'.$CheckboxGroup2.'</p>
<h4>How many individuals/clients from your company will be attending?</h4><p>'.$attending.'</p>
<h4>Will you need meal(s) to be provided?</h4><p>'.$CheckboxGroup3.'</p>
<h4>Do you need research service(s)?</h4><p>'.$CheckboxGroup4.'</p>
<h4>Additional Information</h4><p>'.$additionalinfo.'</p>';
// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: '.$name.'<'.$email.'>'. "\r\n";
// Send email
if(mail($toEmail,$emailSubject,$htmlContent,$headers)){
$statusMsg = 'Your contact request has been submitted successfully !';
$msgClass = 'succdiv';
}else{
$statusMsg = 'Your contact request submission failed, please try again.';
$msgClass = 'errordiv';
}
}
}else{
$statusMsg = 'Please fill all the fields.';
$msgClass = 'errordiv';
}
}
?>
Any help pointing out my error would be appreciated.
If you are getting this message:
Your contact request submission failed, please try again.
Then this portion of the code is throwing that message:
// Send email
if(mail($toEmail,$emailSubject,$htmlContent,$headers)){
$statusMsg = 'Your contact request has been submitted successfully !';
$msgClass = 'succdiv';
}else{
$statusMsg = 'Your contact request submission failed, please try again.';
$msgClass = 'errordiv';
}
Which means that the mail() function is returning false. Make sure that the mail() function works by passing in parameters you know are valid, such as those from the other contact form you say is working. Also, maybe try removing the $headers and see if that helps, since that part is optional.
i have checked your code and every time it's working but you don't handle it if checked box not selected that time occurring error just handle it,
may be use miss it checked boxed selection .
other wise what type of error occurring ?
I'm working on contact form for my site, everything work good if i fill the inputs in English language but if i fill the inputs in arabic language i don't receive any emails, how i can fix this ?
this is my code :
HTML code :
<section class="body">
<form action="form.php" method="post" enctype="multipart/form-data">
<h1 class="title">Contact</h1>
<label></label>
<input name="d_name" required="required" placeholder="أسم المندوب">
<label></label>
<input name="d_phone" type="text" required="required" placeholder="رقم هاتف المندوب">
<label></label>
<input name="c_name" type="text" required="required" placeholder="أسم المشترك">
<label></label>
<input name="phonee" required="required" type="text" placeholder="رقم هاتف المشترك" />
<label></label>
<select class="dropdown-select" name="comp" required="">
<option disabled="disabled" selected="selected" value="">أختر الشركة</option>
<option value="جولان">جولان</option>
<option value="بارتنير">بارتنير</option>
<option value="بلفون">بلفون</option>
<option value="تيلزار 019">تيلزار 019</option>
</select>
<label></label>
<select name="type" required="">
<option disabled="disabled" selected="selected" value="">اختر نوع الرقم</option>
<option value="فاتورة">فاتورة</option>
<option value="كرت">كرت</option>
</select>
<label></label>
<input name="sim" required="required" type="text" placeholder="رقم الشريحة" />
<label></label>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
PHP code :
<?php
$name = $_POST['d_name'];
$phone = $_POST['d_phone'];
$cname = $_POST['c_name'];
$cphone = $_POST['phonee'];
$comp = $_POST['comp'];
$sim = $_POST['sim'];
$type = $_POST['type'];
$message = $_POST['message'];
$from = 'From:' . $_POST['d_name'];
$to = 'Noor_Phone#hotmail.com';
$subject = 'Email Inquiry';
$body = "Delegate Name: $name\n Delegate phone: $phone\n\n\n Customer Name: $cname\n Customer Phone: $cphone\n Line Type: $type\n Company: $comp\n Sim Number: $sim\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Thank you for your email!</p>';
} else {
echo '<p>Oops! An error occurred. Try sending your message again. </p>';
}
}
?>
Instead of using php built-in mail function, use phpmailer. This will solve your problem. Using this class you have the option to set charset:
$mail->CharSet = 'UTF-8';
For additional troubleshooting, you can
<meta charset="utf-8">
You also have the option to include charset attribute in the form tag:
<form action="form.php" method="post"
enctype="multipart/form-data" accept-charset="utf-8">
Or have a look at this old SO answer on sending arabic content in email.
Hope this may help.
Setting the Html Lang might help this situation try this
<html lang="ar">
Referenced from http://www.w3schools.com/tags/ref_language_codes.asp
thanks for helping ,this is the answer:
HTML Code:
<h1 class="title">Contact</h1>
<label></label>
<input name="d_name" required="required" placeholder="أسم المندوب">
<label></label>
<input name="d_phone" type="text" required="required" placeholder="رقم هاتف المندوب">
<label></label>
<input name="c_name" type="text" required="required" placeholder="أسم المشترك">
<label></label>
<input name="phonee" required="required" type="text" placeholder="رقم هاتف المشترك" />
<label></label>
<select class="dropdown-select" name="comp" required="">
<option disabled="disabled" selected="selected" value="">أختر الشركة</option>
<option value="جولان">جولان</option>
<option value="بارتنير">بارتنير</option>
<option value="بلفون">بلفون</option>
<option value="تيلزار 019">تيلزار 019</option>
</select>
<label></label>
<select name="type" required="">
<option disabled="disabled" selected="selected" value="">اختر نوع الرقم</option>
<option value="فاتورة">فاتورة</option>
<option value="كرت">كرت</option>
</select>
<label></label>
<input name="sim" required="required" type="text" placeholder="رقم الشريحة" />
<label></label>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
PHP Code:
<?php
$mail->CharSet = 'UTF-8';
$name = $_POST['d_name'];
$phone = $_POST['d_phone'];
$cname = $_POST['c_name'];
$cphone = $_POST['phonee'];
$comp = $_POST['comp'];
$sim = $_POST['sim'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent="Delegate Name: $name\n Delegate phone: $phone\n\n\n Customer Name: $cname\n Customer Phone: $cphone\n Line Type: $type\n Company: $comp\n Sim Number: $sim\n Message:\n $message";
$recipient = "Noor_Phone#hotmail.com";
$subject = "Contact Form";
$mailheader = "From: admin#4uphone.co.il";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='contact.html' style='text- decoration:none;color:#ff0099;'> Return Home</a>";
?>
I have a webpage that has two contact forms and the second one is working fine but I can't seem to get the first one to work. I am fairly new to php. Thanks in advance for the help. Here's the html:
<h3>Message Us</h3>
<form action="?" method="POST" onsubmit="return saveScrollPositions(this);">
<input type="hidden" name="scrollx" id="scrollx" value="0" />
<input type="hidden" name="scrolly" id="scrolly" value="0" />
<div id="msgbox1">
<label for="name2">Name:</label>
<input type="text" id="name2" name="name2" placeholder=" Required" />
<label for="email2">Email:</label>
<input type="text" id="email2" name="email2" placeholder=" Required" />
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone" placeholder="" />
<label for= "topic">Topic:</label>
<select id="topic" name="topic">
<option value="general">General</option>
<option value="stud">Property Price Enquiry</option>
<option value="sale">Bull Sale Enquiry</option>
</select>
</div><!--- msg box 1 -->
<div id="msgbox2">
<textarea id="message" name="message" rows="7" colums="25" placeholder="Your Message?"></textarea>
<p id="feedback2"><?php echo $feedback2; ?></p>
<input type="submit" value="Send Message" />
</div><!--- msg box 2 -->
</form><!--- end form -->
</div><!--- end message box -->
And here's the php:
<?php
$to2 = '418#hotmail.com'; $subject2 = 'MPG Website Enquiry';
$name2 = $_POST ['name2']; $email2 = $_POST ['email2']; $phone = $_POST ['phone']; $topic = $_POST ['topic']; $message = $_POST ['message'];
$body2 = <<<EMAIL
This is a message from $name2 Topic: $topic
Message: $message
From: $name2 Email: $email2 Phone: $phone
EMAIL;
$header2 = ' From: $email2';
if($_POST['submit']=='Send Message'){
if($name2 == '' || $email2 == '' || $message == ''){
$feedback2 = '*Please fill out all the fields';
}else {
mail($to2, $subject2, $body2, $header2);
$feedback2 = 'Thanks for the message. <br /> We will contact you soon!';
} } ?>
For the saveScrollPositions I use the following php and script:
<?php
$scrollx = 0;
$scrolly = 0;
if(!empty($_REQUEST['scrollx'])) {
$scrollx = $_REQUEST['scrollx'];
}
if(!empty($_REQUEST['scrolly'])) {
$scrolly = $_REQUEST['scrolly'];
}
?>
<script type="text/javascript">
window.scrollTo(<?php echo "$scrollx" ?>, <?php echo "$scrolly" ?>);
</script>
You have a mistake in your HTML part i.e.
<input type="submit" value="Send Message" />
add attribute name also in this input type like this-
<input type="submit" value="Send Message" name="submit" />
one thing more to correct in your php script is write-
$header2 = "From: ".$email2; instead of $header2 = ' From: $email2';
now try it.
What do you return in "saveScrollPositions" function? if you return false the form submit wont fire.
Can some help me with the form on this page: http://riccipsych.com/referrals.php? The form fields are not being passed to the form handler: http://riccipsych.com/sendmail.php. I'm getting an email from my form with all the form labels but, the fields are blank.
Here's the code for each page:
referrals.php
<p><?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /></p>
<form method="post" action="sendmail.php">
<h3>Client Information:</h3>
<label for="attn" class="label">Referral To:</label>
<select id="attn" name="select">
<option value="General">General</option>
<option value="Dr. Tammie Ricci, C.Psych.">Dr. Tammie Ricci, C.Psych.</option>
<option value="Dr. Paul Mendella, C.Psych.">Dr. Paul Mendella, C.Psych.</option>
<option value="Dr. Paul Roy, Psychiatrist">Dr. Paul Roy, Psychiatrist</option>
</select>
<br />
<label for="cname" class="label">Client Name:</label>
<input id="cname" type="text" name="textfield" maxlength="60">
<br />
<label for="caddress" class="label">Client Address:</label>
<input id="caddress" type="text" name="textfield" maxlength="60">
<br />
<label for="ccity" class="label">Client City:</label>
<input id="ccity" type="text" name="textfield" maxlength="50">
<br />
<label for="cprovince" class="label">Client Province:</label>
<select id="cprovince" name="select">
<option value="NFLD">NFLD </option>
<option value="NS">NS </option>
<option value="PEI">PEI </option>
<option value="NB">NB </option>
<option value="PQ">PQ </option>
<option value="ON">ONT </option>
<option value="MAN">MAN </option>
<option value="SASK">SASK </option>
<option value="ALTA">ALTA </option>
<option value="BC">BC </option>
<option value="YT">YT </option>
<option value="NWT">NWT </option>
<option value="NVT">NVT </option>
</select>
<br />
<label for="cpcode" class="label">Client Postal Code:</label>
<input id="cpcode" type="text" name="textfield" maxlength="7">
<br />
<label for="chphone" class="label">Client Home Phone:</label>
<input id="chphone" type="text" name="textfield" maxlength="15">
<br />
<label for="cwphone" class="label">Client Work Phone:</label>
<input id="cwphone" type="text" name="textfield" maxlength="15">
<br />
<label for="ccphone" class="label">Client Cell Phone:</label>
<input id="ccphone" type="text" name="textfield" maxlength="15">
<br />
<label for="cdob" class="label">Client Date of Birth</label>
<input id="cdob" type="text" name="textfield" maxlength="20">
<br />
<label for="chmessage" class="label">Can we leave a message at the client's home?</label>
<select id="chmessage" name="select">
<option value="Yes">Yes </option>
<option value="No">No </option>
</select>
<br />
<label for="cwmessage" class="label">Can we leave a message at the client's workplace?</label>
<select id="cwmessage" name="select">
<option value="Yes">Yes </option>
<option value="No">No </option>
</select>
<br />
<br />
<h3>Referral Information</h3>
<label for="rname" class="label">Referral Name:</label>
<input id="rname" type="text" name="textfield" maxlength="60">
<br />
<label for="raddress" class="label">Referral Address:</label>
<input id="raddress" type="text" name="textfield" maxlength="60">
<br />
<label for="rcity" class="label">Referral City:</label>
<input id="rcity" type="text" name="textfield" maxlength="50">
<br />
<label for="rprovince" class="label">Referral Province:</label>
<select id="rprovince" name="select">
<option value="NFLD">NFLD </option>
<option value="NS">NS </option>
<option value="PEI">PEI </option>
<option value="NB">NB </option>
<option value="PQ">PQ </option>
<option value="ON">ONT </option>
<option value="MAN">MAN </option>
<option value="SASK">SASK </option>
<option value="ALTA">ALTA </option>
<option value="BC">BC </option>
<option value="YT">YT </option>
<option value="NWT">NWT </option>
<option value="NVT">NVT </option>
</select>
<br />
<label for="rpcode" class="label">Referral Postal Code:</label>
<input id="rpcode" type="text" name="textfield" maxlength="7">
<br />
<label for="rwphone" class="label">Referral Work Phone:</label>
<input id="rwphone" type="text" name="textfield" maxlength="15">
<br />
<label for="remail" class="label">Referral E-Mail:</label>
<input id="remail" type="text" name="textfield" maxlength="80">
<br />
<label for="notes" class="label">Notes:</label>
<textarea id="notes" style="width: 300px; height: 150px;" name="textarea"></textarea>
<br />
<br />
<p><input type="submit" value="Send Form" /></p>
sendmail.php
<?php
if(!$remail == "" && (!strstr($remail,"#") || !strstr($remail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($rname) || empty($remail) || empty($cname )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Referral To: $attn \n
Client Name: $cname \n
Client Address: $caddress \n
Client City: $ccity \n
Client Province: $cprovince \n
Client Postal Code: $cpcode \n
Client Home Phone: $chphone \n
Client Work Phone: $cwphone \n
Client Cell Phone: $ccphone \n
Client Date of Birth: $cdob \n
Leave Message at Client's Home: $chmessage \n
Leave Message at Client's Workplace: $chmessage \n
Referral Name: $rname \n
Referral Address: $raddress \n
Referral City: $rcity \n
Referral Province: $rprovince \n
Referral Postal Code: $rpcode \n
Referral Work Phone: $rwphone \n
Referral Email: $remail \n
Notes: $notes \n
From: $rname ($remail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $remail\r\n";
mail("info#riccipsych.com", $subject, $message, $from);
?>
<h1>Thank You</h1>
<p>Thank you for submitting your referral. We will contact you shortly.</p>
It is still not working. I changed sendmail.php to sendeail.php and added:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$attn = $_POST['attn'];
$cname = $_POST['cname'];
$caddress = $_POST['caddress'];
$ccity = $_POST['ccity'];
$cprovince = $_POST['cprovince'];
$cpcode = $_POST['cpcode'];
$chphone = $_POST['chphone'];
$cwphone = $_POST['cwphone'];
$ccphone = $_POST['ccphone'];
$cdob = $_POST['cdob'];
$chmessage = $_POST['chmessage'];
$cwmessage = $_POST['cwmessage'];
$rname = $_POST['rname'];
$raddress = $_POST['raddress'];
$rcity = $_POST['rcity'];
$rprovince = $_POST['rprovince'];
$rpcode = $_POST['rpcode'];
$rwphone = $_POST['rwphone'];
$remail = $_POST['remail'];
$notes = $_POST['notes'];
if(!$remail == "" && (!strstr($remail,"#") || !strstr($remail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($rname) || empty($remail) || empty($cname )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Referral To: $attn \n
Client Name: $cname \n
Client Address: $caddress \n
Client City: $ccity \n
Client Province: $cprovince \n
Client Postal Code: $cpcode \n
Client Home Phone: $chphone \n
Client Work Phone: $cwphone \n
Client Cell Phone: $ccphone \n
Client Date of Birth: $cdob \n
Leave Message at Client's Home: $chmessage \n
Leave Message at Client's Workplace: $chmessage \n
Referral Name: $rname \n
Referral Address: $raddress \n
Referral City: $rcity \n
Referral Province: $rprovince \n
Referral Postal Code: $rpcode \n
Referral Work Phone: $rwphone \n
Referral Email: $remail \n
Notes: $notes \n
From: $rname ($remail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $remail\r\n";
mail("info#riccipsych.com", $subject, $message, $from);
?>
<h1>Thank You</h1>
<p>Thank you for submitting your referral. We will contact you shortly.</p>
You need to define your variables in sendmail.php with $_POST or $_REQUEST:
$remail = $_REQUEST['remail'];
To see what variables you have, you can also use the following code on sendmail.php
foreach($_REQUEST as $k => $v)
echo "$k = $v\n";
I have created a simple HTML form, and process it using PHP.
When I try to submit the form, it is giving me the error message I created for not filling in all the required boxes. I have checked and rechecked the variables, and I cannot figure out why it is giving me that message with all the fields filled in.
HTML:
<form name="volunteer" action="form-to-email3.php" method="post">
<label>Last Name*: </label><input type="text" name="lastname" /><br />
<label>First Name*: </label><input type="text" name="firstname" /><br />
<label>Middle Initial: </label><input type="text" name="initial" size=1 maxlength=1 /><br /><br />
<label>Date of Birth*: </label><INPUT NAME="month" input type="tel" SIZE=2 MAXLENGTH=2
onKeyPress="return numbersonly(this, event)">/<INPUT NAME="day" input type="tel" SIZE=2 MAXLENGTH=2
onKeyPress="return numbersonly(this, event)">/<INPUT NAME="year" input type="tel" SIZE=4 MAXLENGTH=4
onKeyPress="return numbersonly(this, event)">
<SCRIPT TYPE="text/javascript">
<!--
autojump("month", "day", 2); autojump("day", "year", 2);
//-->
</SCRIPT><br /><br />
<label>Gender*:</label><input type="radio" name="gender" value="Male"> Male
<input type="radio" name="gender" value="Female"> Female
<br /> <br />
<label>Street Address*: </label><input type="text" name="streetaddress" /><br />
<label>Address Line 2: </label><input type="text" name="addressline2" /><br />
<label>City*: </label><input type="text" name="city" /><br />
<label>State/Province/Region*: </label><input type="text" name="state" /><br />
<label>Zipcode*: </label>
<INPUT NAME="zip" input type="tel" SIZE=5 MAXLENGTH=5
onKeyPress="return numbersonly(this, event)"><br />
<label>Country: </label>
<select class="element select medium" id="element_3_6" name="country">
<option value="" selected="selected"></option>
<option value="Afghanistan" >Afghanistan</option>
<option value="Albania" >Albania</option>
</select>
<br /><br />
<label>Email*: </label><input type="email" name="email" /><br /><br />
<label>Cell Phone*: </label>(<INPUT NAME="areacode" input type="tel" SIZE=3 MAXLENGTH=3
onKeyPress="return numbersonly(this, event)">)<INPUT NAME="cellphone" input type="tel"SIZE=7 MAXLENGTH=7
onKeyPress="return numbersonly(this, event)"><br />
<SCRIPT TYPE="text/javascript">
<!--
autojump("areacode", "cellphone", 3);
//-->
</SCRIPT>
<label>Daytime Phone*: </label>(<INPUT NAME="daytime_phone_area" input type="tel" SIZE=3 MAXLENGTH=3
onKeyPress="return numbersonly(this, event)">)<INPUT NAME="daytime_phone" input type="tel"SIZE=7 MAXLENGTH=7
onKeyPress="return numbersonly(this, event)"><br /><br />
<SCRIPT TYPE="text/javascript">
<!--
autojump("daytime_phone_area", "daytime_phone", 3);
//-->
</SCRIPT>
<label>T-Shirt Size*: </label><input type="radio" name="shirt_size" value="Small"> Small
<input type="radio" name="shirt_size" value="Medium"> Medium
<input type="radio" name="shirt_size" value="Large"> Large
<input type="radio" name="shirt_size" value="XL"> XL
<input type="radio" name="shirt_size" value="2XL"> 2XL
<input type="radio" name="shirt_size" value="Other"> Other (Please provide)<br />
<label>Other:</label><input type="text" name="other size" /><br /><br />
<p>In which area will you be helping*:</p>
<select>
<option name= "position" value= "Pastor">Pastor</option>
<option name= "position" value="Nursing Staff">Nursing Staff</option>
<option name= "position" value="Camp Staff">Camp Staff (Including Huddle Leaders)</option>
<option name= "position" value="Other Staff">Other Staff</option>
</select><br /><br />
<label>Dates Attending*: <br />(Please check all dates you can be present)</label>
<input type="checkbox" name="dates" value="7/6">July 6
<input type="checkbox" name="dates" value="7/7" />July 7
<input type="checkbox" name="dates" value="7/8">July 8
<input type="checkbox" name="dates" value="7/9">July 9
<input type="checkbox" name="dates" value="7/10">July 10
<input type="checkbox" name="dates" value="7/11">July 11
<input type="checkbox" name="dates" value="7/12">July 12<br /><br /><br /><br />
<label>What is the best way to contact you*? </label><input type="text" name="contactmethod" /><br /><br /><br />
<b>Electronic Submission</b>
<p>I understand that by filling in my name here, it shall act as a binding, legal signagure. </p>
<label>Electronic Signagure*: </label><input type="text" name="signature" /><br />
<label>Date*: </label><INPUT NAME="signature_month" input type="tel" SIZE=2 MAXLENGTH=2
onKeyPress="return numbersonly(this, event)">/<INPUT NAME="signature_day" input type="tel" SIZE=2 MAXLENGTH=2
onKeyPress="return numbersonly(this, event)">/<INPUT NAME="signature_year" input type="tel" SIZE=4 MAXLENGTH=4
onKeyPress="return numbersonly(this, event)">
<SCRIPT TYPE="text/javascript">
<!--
autojump("signature_month", "signature_day", 2); autojump("signature_day", "signature_year", 2);
//-->
</SCRIPT><br /><br /><br /><br /><br />
<input type="submit" value="Submit">
</form>
PHP:
<?php
if($_SERVER['REQUEST_METHOD'] !== 'POST')
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
die;
}
$firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $initial = $_POST['initial']; $streetaddress = $_POST['streetaddress']; $addressline2 = $_POST['addressline2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $email = $_POST['email']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $gender = $_POST['gender']; $areacode = $_POST['areacode']; $cellphone = $_POST['cellphone']; $shirtsize = $_POST['shirt_size']; $country = $_POST['country']; $dayarea = $_POST['daytime_phone_area']; $dayphone = $_POST['daytime_phone']; $shirtsizeother = $_POST['other']; $dates = $_POST['dates']; $signature = $_POST['signature']; $signday = $_POST['signature_day']; $signmonth = $_POST['signature_month']; $signyear = $_POST['signature_year']; $position = $_POST['position']; $contactmethod = $_POST['contactmethod'];
//Validate first
/*
Simple form validation
check to see if required fields were entered
*/
if ($_POST['firstname'] == "" || $_POST['lastname'] == "" || $_POST['streetaddress'] == "" || $_POST['city'] == "" || $_POST['state'] == "" || $_POST['zip'] == "" || $_POST['email'] == "" || $_POST['month'] == "" || $_POST['day'] == "" || $_POST['year'] == "" || $_POST['gender'] == "" || $_POST['areacode'] == "" || $_POST['cellphone'] == "" || $_POST['daytime_phone_area'] == "" || $_POST['daytime_phone'] == "" || $_POST['dates'] == "" || $_POST['signature'] == "" || $_POST['signature_day'] == "" || $_POST['signature_month'] == "" || $_POST['shirt_size'] == "" || $_POST['signature_year'] == "" || $_POST['position'] == "" || $_POST['contactmethod'] == "" ) {
echo "Please fill in all required boxes.";}
else {
$email_from = 'chris569x#gmail.com';//<== update the email address
$email_subject = "New Volunteer Registration"; $email_body = "You have received a new volunteer registration.\n".
"Volunteer: $firstname $initial $lastname \n".
"Address: $streetaddress \n".
"$addressline2 \n".
"$city, $state $zip \n".
"Email: $email \n".
"Date of Birth: $month/$day/$year \n".
"Gender: $gender \n".
"Cell Phone: ($areacode) $cellphone \n".
"Daytime Phone: ($dayarea) $dayphone \n".
"T-Shirt Size: $shirtsize $shirtsizeother \n".
"Dates availible to volunteer: $dates \n".
"Electronic Signature: $signature $signmonth/$signday/$signyear \n".
"Preferred contact method: $contactmethod \n";
$to = "chris569x#gmail.com";//<== update the email address
$headers = "From: $email_from \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thanks2.htm');
echo "<meta http-equiv='refresh' content='0; url=thanks2.htm'>";
}
?>
I believe that you need to change your select for position.
It appears that the name is not coming over to the post page because you put the name in instead of the . Fix that and you should be good to go.
Congratulations, your server seems to be properly configured! The variables $city should not hold any data. You have to use $_POST['city'] or $_REQUEST['city'] instead.
Some hosts may still support submitting variables directly to the $variables, but this is not a safe configuration.
For instance:
...
if (password_check($username,$password)) {
$access = 'yes'
}
...
if ('yes'==$access) { ... }
Could be hacked by submitting script.php&access=yes
So you have to use $_POST['variable'] directly or copy it in the $variable, first.