<!-- PHP CONTACT FORM -->
<?php
$look = $_POST['look'];
$design = $_POST['design'];
$old_website = $_POST['old_website'];
$redesign = $_POST['redesign'];
?>
<?php
$field_name = $_POST['user_name'];
$field_email = $_POST['user_email'];
$field_message = $_POST['user_message'];
$mail_to = 'alzirabarretto#gmail.com';
$subject = 'Queries';
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message.');
window.location = '/website_form.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to alzirabarretto#gmail.com');
window.location = '/website_form.html';
</script>
<?php
}
?>
I update the php code. When sending the mail it works fine but i don't understand when I didn't received my mail. I have change the radio value according what you have said. And what about the url which I create the input type? I'm bit little confused how to do in php code.
I think this line is wrong.
$radio = $_POST['look' , 'design', 'old_website' , 'redesign'];
Try capturing them separately like this,
$look = $_POST['look'];
$design = $_POST['design'];
$old_website = $_POST['old_website'];
$redesign = $_POST['redesign'];
And even for radio group LOOK, try changing the corresponding values. Or you will get value as radio_1,radio_2, ...
Related
I made a simple contact form using HTML & PHP and I tested, it works perfectly, but when I wanna write in Kurdish or Arabic language the text not displaying properly in my email it looks like that: ÚÛبÛÙ
<?php
$field_name = $_POST['cf_name'];
$field_mobile = $_POST['cf_mobile'];
$field_service = $_POST['cf_service'];
$field_customer = $_POST['cf_customer'];
$field_message = $_POST['cf_message'];
$mail_to = 'email#email.co';
$subject = 'داواکاری بینینی بەڕێوەبەران';
$body_message = 'From: '.$field_name."\n";
$body_message .= 'mobile: '.$field_mobile."\n";
$body_message .= 'Manager: '.$field_service."\n";
$body_message .= 'Sender: '.$field_customer."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Message send successfully :)');
window.location = 'https://#.co/interview';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Failed :( Please call the developer!');
window.location = 'https://#/interview';
</script>
<?php
}
?>
Please try below code:
mail( $mail_to, utf8_decode($subject), utf8_decode($body_message), utf8_decode($headers) );
Good day everyone, this is my first time to post here so pls bear with me. I need your help guys, I'm an artist that knows basic html5/css that's why i'm really not good in php.
Anyway I have a project that has a contact form, I just realized that yahoo mail is not working when I fill up the form online, but gmail's are good. Below is my php code. I've been following this PHP Mail() Contact-us form works fine if entering a Gmail sending address, but not with Yahoo but I really can't do it on my own! A brother needs your help. Thank you.
<?php
$field_name = $_POST['cf_name'];
$field_brand = $_POST['cf_brand'];
$field_category = $_POST['cf_category'];
$field_email = $_POST['cf_email'];
$field_facebook = $_POST['cf_facebook'];
$field_instagram = $_POST['cf_instagram'];
$field_number = $_POST['cf_number'];
$field_message = $_POST['cf_message'];
$mail_to = 'dulcetlifestylehub#gmail.com';
$subject = 'DULCET LIFESTYLE - BECOME FAMILY: '.$field_name;
$body_message = 'From Owner: '.$field_name."\n";
$body_message .= 'Brand Name: '.$field_brand."\n";
$body_message .= 'Brand Category: '.$field_category."\n";
$body_message .= 'Email: '.$field_email."\n";
$body_message .= 'Facebook: '.$field_facebook."\n";
$body_message .= 'Instagram: '.$field_instagram."\n";
$body_message .= 'Number: '.$field_number."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'becomefamily.htm';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to dulcetlifestylehub#gmail.com');
window.location = 'becomefamily.htm';
</script>
<?php
}
?>
I need help with the first $headers line.
I need the from to look like this:
name <email>
actually
$field_name <$field_email>
It should show from email in email client
Personname <person#emailaddress.com
How can I achieve this?
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$field_phone = $_POST['cf_phone'];
$mail_to = 'from#email.com';
$subject = 'Enquiry from Website, From: '.$field_name;
$body_message = 'Enquiry submitted to business, via website contact form.';
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Telephone Number: '.$field_phone."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '$field_name' <'$field_email'>'"\n";
$headers .= 'Reply-To: '.$field_email.;
$mail_status = mail($mail_to, $subject, $body_message, $headers);
include 'contactendd.php';
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
window.location = 'thanks.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
window.location = 'thanksfailed.html';
</script>
<?php
}
?>
Thanks very much for your help
This line is the right idea:
$headers = 'From: '$field_name' <'$field_email'>'"\n";
but it should read
$headers = 'From: ' . $field_name . ' <' . $field_email . '>\n';
Just missed the periods to concatenate
Headers should be separated by CRLF "\r\n" -- not just \n.
the issue was making a nice looking html contact form design as well as the issue with accepting the user sent mail via a html table instead of a plain text mail
this is the code i am using this is my first work on php
and it's working fine if i am using the web based mail account (gmail)
though if i move the recipent to another account(to my clients domains-email account)
it is then accepting an unregognized characters not ??????? but something like
זוהי ×¤× ×™×” בקשר לבדיקת מייל × ×•×¡
as i said brefore in gmail through the browser it is perfet though
the language in this case is hebrew as you could see in the code below in the subject or body for example
what is missing in this code so it will be ok not only in gmail web mail ?
<?php
$field_name = $_POST['sender_name'];
$field_telephon = $_POST['sender_telephon'];
$field_email = $_POST['sender_mail'];
$field_Subject = $_POST['sender_Subject'];
$field_message = $_POST['sender_message'];
$StrDivOpen = "<div dir='rtl'>";
$StrDivClose = "</div>";
$StrTableOpen = "<table border='1' style='width:260px; font-family:Arial;'>";
$StrTableClose = "</table>";
$StrTrOpen ="<tr>";
$StrTdOpenHd = "<td style='background-color:#fcf7da; width:100px;'>";
$StrTdOpenCont = "<td style='background-color:#dae3a5; width:130px;'>";
$StrTrClose="</tr>";
$StrTdClose="</td>";
$StrBr = "<br />";
$mail_to = 'v7host#gmail.com';
$subject = 'לקוח HostDns, בשם : '.$field_name." , נושא: ".$field_Subject;
$body_message = $StrDivOpen.$StrTableOpen;
$body_message .= $StrTrOpen.$StrTdOpenHd.'מאת : '.$StrTdClose.$StrTdOpenCont.$field_name.$StrTdClose.$StrTrClose;
$body_message .= $StrTrOpen.$StrTdOpenHd.'טלפון : '.$StrTdClose.$StrTdOpenCont.$field_telephon.$StrTdClose.$StrTrClose;
$body_message .= $StrTrOpen.$StrTdOpenHd.'כתובת מייל : '.$StrTdClose.$StrTdOpenCont.$field_email.$StrTdClose.$StrTrClose;
$body_message .= "<tr><td colspan=2 style='background-color:#1cbfbf;'>תוכן ההודעה : </td></tr><tr><td colspan=2 style='background-color:#81c3b2;'>".$StrBr.$field_message."</td></tr></table></div>";
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thanks for the post. We will contact you soon..');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Sending failed. Please send an email to v7host#gmail.com');
window.location = 'contact.html';
</script>
<?php
}
?>
You need to change your encoding to UTF-8:
Content-type: text/html; charset=utf-8
The current encoding you're using (ISO/IEC 8859-1) cannot handle chars from non-Western languages.
I'm very new to PHP and am using a basic template 'send-mail' form on a contact page.
It's been requested that I send the email out to multiple email addresses when the "Submit" button is clicked. I've searched around & haven't quite found what I needed. What code do I need to add into the form below in order to send this out to multiple email addresses?
<?php
$mail_to = 'daniel30293#gmail.com'; // specify your email here
// Assigning data from the $_POST array to variables
$name = $_POST['sender_name'];
$mail_from = $_POST['sender_email'];
$phone = $_POST['sender_phone'];
$web = $_POST['sender_web'];
$company = $_POST['sender_company'];
$addy = $_POST['sender_addy'];
$message = $_POST['sender_message'];
// Construct email subject
$subject = 'Web Prayer Request from ' . $name;
// Construct email body
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Phone: ' . $phone . "\r\n";
$body_message .= 'Prayer Request: ' . $message;
// Construct email headers
$headers = 'From: ' . $name . "\r\n";
$headers .= 'Reply-To: ' . $mail_from . "\r\n";
$mail_sent = mail($mail_to, $subject, $body_message, $headers);
if ($mail_sent == true){ ?>
<script language="javascript" type="text/javascript">
alert('Your prayer request has been submitted - thank you.');
window.location = 'prayer-request.php';
</script>
<?php } else { ?>
<script language="javascript" type="text/javascript">
alert('Message not sent. Please, notify the site administrator admin#bondofperfection.com');
window.location = 'prayer-request.php';
</script>
<?php
}
?>
Your help is greatly appreciated.
You implode an array of recipients:
$recipients = array('jack#gmail.com', 'jill#gmail.com');
mail(implode(',', $recipients), $submit, $message, $headers);
See the PHP: Mail function reference - http://php.net/manual/en/function.mail.php
Receiver, or receivers of the mail.
The formatting of this string must comply with » RFC 2822. Some examples are:
user#example.com
user#example.com, anotheruser#example.com
User <user#example.com>
User <user#example.com>, Another User <anotheruser#example.com>
Just add multiple recipients comma seperated in your $mail_to variable like so:
$mail_to = 'nobody#example.com,anotheruser#example.com,yetanotheruser#example.com';
See
mail() function in PHP
Here is a simple example:
<?php
// Has the form been submitted?
// formSubmit: <input type="submit" name="formSubmit">
if (isset($_POST['formSubmit'])) {
// Set some variables
$required_fields = array('name', 'email');
$errors = array();
$success_message = "Congrats! Your message has been sent successfully!";
$sendmail_error_message = "Oops! Something has gone wrong, please try later.";
// Cool the form has been submitted! Let's loop through the required fields and check
// if they meet our condition(s)
foreach ($required_fields as $fieldName) {
// If the current field in the loop is NOT part of the form submission -OR-
// if the current field in the loop is empty, then...
if (!isset($_POST[$fieldName]) || empty($_POST[$fieldName])) {
// add a reference to the errors array, indicating that these conditions have failed
$errors[$fieldName] = "The {$fieldName} is required!";
}
}
// Proceed if there aren't any errors
if (empty($errors)) {
$name = htmlspecialchars(trim($_POST['name']), ENT_QUOTES, 'UTF-8' );
$email = htmlspecialchars(trim($_POST['email']), ENT_QUOTES, 'UTF-8' );
// Email Sender Settings
$to_emails = "anonymous1#example.com, anonymous2#example.com";
$subject = 'Web Prayer Request from ' . $name;
$message = "From: {$name}";
$message .= "Email: {$email}";
$headers = "From: {$name}\r\n";
$headers .= "Reply-To: {$email}\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
if (mail($to_emails, $subject, $message, $headers)) {
echo $success_message;
} else {
echo $sendmail_error_message;
}
} else {
foreach($errors as $invalid_field_msg) {
echo "<p>{$invalid_field_msg}</p>";
}
}
}