Can't get the name from $NAME - php

I have a subscription form that contains tow variables $name and $email.
and I get only the $email from the form.I can't get the $name.
I have tried all I knew to fix it, the form is fully working, it sends the code to email and writes to the file,just doesn't give me name!
Thanks.
This is the PHP code:
<?php
header('content-type: application/json');
$o = new stdClass();
$o->status = 'success';
echo json_encode($o);
$Length = 9;
$RandomString = substr(str_shuffle(md5(time())), 0, $Length);
$email = $_POST["email"];
$name = $_POST["author"];
$emailTo = 'info#praia.co.il';
$subject = 'הרשמה לרכישה קבוצתית פראיה ';
$body = "\n\nשם הלקוח: $name \n\nאימייל: $email \n\nקוד קופון: $RandomString";
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailTo, $subject, $body, $headers, $randomString);
$headers2 = "From: Praia <info#praia.co.il>" . "\r\n".
'Reply-To: '.$emailTo."\r\n" .
'Content-Type: text/html; charset=ISO-8859-1\r\n'.
'Return-Path: Praia <info#praia.co.il>\r\n'.
'X-Mailer: PHP/' . phpversion();
$message = '<html><body><center><div style="background:#f0f0f0; font-family:"almoni-tzar";>';
$message .= '<img src="http://praia.co.il/assets/img/logo.png" alt="logo" style="width:150px; height:150px;"></a><br />';
$message .= '<br />';
$message .= " שלום $name, אנו שמחים שהצטרפת לרכישה הקבוצתית של פראיה.</p>";
$message .= '<br>';
$message .= "$RandomString :קוד ההרשמה שלך לרכישה הוא ";
$message .= '<br />';
$message .= "קוד ההרשמה הינו חד פעמי*";
$message .= '<br />';
$message .= '<br />';
$message .= '<br />';
$message .= '<br />';
$message .= ' מעבר לאתר מעבר לתקנון';
$message .= '</div></center></body></html>';
$mailed = true;
if($mailed==true){
mail($email, "פראיה- הרשמה לרכישה קבוצתית.", $message , $headers2);
}else{
echo 'error';
}
if($mailed==true){
//file_put_contents("coupon.txt", $email. . $RandomString . PHP_EOL, FILE_APPEND);
file_put_contents("coupon.txt", $email . " " . $RandomString . "\r\n" , FILE_APPEND | LOCK_EX);
}else{
echo 'error';
}
?>
JS code:
/*
notifyMe jQuery Plugin v1.0.0
Copyright (c)2014 Sergey Serafimovich
Licensed under The MIT License.
*/
(function(e) {
e.fn.notifyMe = function(t) {
var r = e(this);
var i = e(this).find("input[name=email]");
var s = e(this).attr("action");
var o = e(this).find(".note");
e(this).on("submit", function(t) {
t.preventDefault();
var h = i.val();
var p = /^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (p.test(h)) {
$(".message").removeClass("error bad-email success-full");
$(".message").hide().html('').fadeIn();
o.show();
e.ajax({
type: "POST",
url: s,
data: {
email: h
},
dataType: "json",
error: function(e) {
o.hide();
if (e.status == 404) {
$(".message").hide().html('<p class="notify-valid style="font-family:almoni-tzar;"> .אופס, נראה שמשהו השתבש! נסה מאוחר יותר <i class="icon ion-close-round"></i></p>').slideDown();
} else {
$(".message").hide().html('<p class="notify-valid style="font-family:almoni-tzar;"> .אופס, נראה שמשהו השתבש! נסה מאוחר יותר <i class="icon ion-close-round"></i></p>').fadeIn();
}
}
}).done(function(e) {
o.hide();
if (e.status == "success") {
$(".message").removeClass("bad-email").addClass("success-full");
$(".message").hide().html('<p class="notify-valid" style="font-family:almoni-tzar;"> .נרשמת בהצלחה לרכישה הקבוצתית תעודכן בהמשך <i class="icon ion-checkmark-round"></i></p>').fadeIn();
} else {
if (e.type == "ValidationError") {
$(".message").hide().html('<p class="notify-valid style="font-family:almoni-tzar;"> .כתובת המייל נראית לא חוקית, נא הזן כתובת חדשה <i class="icon ion-close-round"></i></p>').fadeIn();
} else {
$(".message").hide().html('<p class="notify-valid style="font-family:almoni-tzar;"> .אופס, נראה שמשהו השתבש! נסה מאוחר יותר <i class="icon ion-close-round"></i></p>').fadeIn();
}
}
})
} else {
$(".message").addClass("bad-email").removeClass("success-full");
$(".message").hide().html('<p class="notify-valid" style="font-family:almoni-tzar;"> .כתובת המייל אינה חוקית נא נסה שנית <i class="icon ion-close-round"></i></p>').fadeIn();
o.hide();
}
// Reset and hide all messages on .keyup()
$("#notifyMe input").keyup(function() {
$(".message").fadeOut();
});
})
}
})(jQuery)

Your ajax call is only sending the mail. You should change
var i = e(this).find("input[name=email]");
...
data: {
email: h
},
To something along the lines of:
var i = e(this).find("input[name=email]");
var authorValue = e(this).find("input[name=author]");
...
data: {
email: h,
author: authorValue
},
While adding on your list above the

Related

WP + AJAX success message

I have a multilingual website where I should show a success message after successful submission. I use ACF filed and wp_send_json_success () to report a successful send, but I get an error in the console. The letter was sent successfully. How can I do it correctly so that I can send a success message?
PHP:
add_action('wp_ajax_nopriv_send_email', 'send_email');
add_action('wp_ajax_send_email', 'send_email');
function send_email() {
$checkbox = $_POST['myCheckboxes'];
if (isset($checkbox)) {
echo $checkbox;
}
$checkbox_hy = $_POST['myCheckboxesHy'];
if (isset($checkbox_hy)) {
echo $checkbox_hy;
}
$checkbox_modal_2 = $_POST['modalCheckboks2'];
if (isset($checkbox_modal_2)) {
echo $checkbox_modal_2;
}
$checkbox_subs = $_POST['subsCheckbox'];
if (isset($checkbox_subs)) {
echo $checkbox_subs;
}
$checkbox_sp = $_POST['supportCheckbox'];
if (isset($checkbox_sp)) {
echo $checkbox_sp;
}
$headers = 'Content-Type: text/html; charset="utf-8"';
$url = $_POST['url'];
$name = $_POST['name'];
$fullname = $_POST['fullname'];
$spFullname = $_POST['spFullname'];
$hy_name = $_POST['hy_name'];
$from = 'contact#test.com';
$to = 'contact#test.com';
$email = $_POST['email'];
$hy_email = $_POST['hy_email'];
$spEmail = $_POST['spEmail'];
$modalEmail = $_POST['modalEmail'];
$subsEmail = $_POST['subsEmail'];
$msg = $_POST['msg'];
$hy_msg = $_POST['hy_msg'];
$modalMsg = $_POST['modalMsg'];
$spMsg = $_POST['spMsg'];
$company = $_POST['company'];
$spCompany = $_POST['spCompany'];
if ($hy_name) {
$subject = '‘Any questions?’ form: ' . $_POST['hy_email'];
} elseif ($name) {
$subject = 'Footer form: ' . $_POST['email'];
} elseif ($fullname) {
$subject = 'Header form: ' . $_POST['modalEmail'];
} elseif ($subsEmail) {
$subject = 'New blog subscription: ' . $_POST['subsEmail'];
} elseif ($spEmail) {
$subject = 'Support form: ' . $_POST['spEmail'];
}
$message .= (!empty($name)) ? '<p><strong>User Name</strong> : ' . $name .' </p>' : '';
$message .= (!empty($email)) ? '<p><strong>User Email</strong> : '. $email .'</p>' : '';
$message .= (!empty($msg)) ? '<p><strong>User Message</strong> : '.$msg .'</p>' : '';
$message .= (!empty($checkbox)) ? '<p><strong>Checkboxs</strong> : '.$checkbox .'</p>' : '';
$message .= (!empty($hy_name)) ? '<p><strong>User Name</strong> : '.$hy_name .'</p>' : '';
$message .= (!empty($hy_email)) ? '<p><strong>User Email</strong> : '.$hy_email .'</p>' : '';
$message .= (!empty($hy_msg)) ? '<p><strong>User Message</strong> : '.$hy_msg .'</p>' : '';
$message .= (!empty($checkbox_hy)) ? '<p><strong>Checkbox</strong> : '.$checkbox_hy .'</p>' : '';
$message .= (!empty($fullname)) ? '<p><strong>Full Name</strong> : ' . $fullname .' </p>' : '';
$message .= (!empty($modalEmail)) ? '<p><strong>User Email</strong> : ' . $modalEmail .' </p>' : '';
$message .= (!empty($company)) ? '<p><strong>Company</strong> : ' . $company .' </p>' : '';
$message .= (!empty($modalMsg)) ? '<p><strong>User Message</strong> : ' . $modalMsg .' </p>' : '';
$message .= (!empty($checkbox_modal_2)) ? '<p><strong>Checkbox</strong> : '.$checkbox_modal_2 .'</p>' : '';
$message .= (!empty($subsEmail)) ? '<p><strong>User Email</strong> : '. $subsEmail .'</p>' : '';
$message .= (!empty($checkbox_subs)) ? '<p><strong>Checkbox</strong> : '.$checkbox_subs .'</p>' : '';
$message .= (!empty($spFullname)) ? '<p><strong>User Name</strong> : '.$spFullname .'</p>' : '';
$message .= (!empty($spEmail)) ? '<p><strong>User Email</strong> : '.$spEmail .'</p>' : '';
$message .= (!empty($spCompany)) ? '<p><strong>Company</strong> : ' . $spCompany .' </p>' : '';
$message .= (!empty($spMsg)) ? '<p><strong>User Message</strong> : '.$spMsg .'</p>' : '';
$message .= (!empty($checkbox_sp)) ? '<p><strong>Checkbox</strong> : '.$checkbox_sp .'</p>' : '';
$message .= (!empty($url)) ? '<p><strong>Url:</strong> : '.$url .'</p>' : '';
$message .= '</body></html>';
$send_mail = mail($to, $subject, $message, $headers);
echo $send_mail;
if($send_mail) {
$data = get_field('success_message', 'option');
wp_send_json_success($data, 200);
}
return $msg;
die();
}
AJAX:
jQuery('.submit').on('click', function(e) {
e.preventDefault();
// All data from form
var str = $(this).closest('form').serialize();
$("#contact-form input:checkbox:not(:checked)").each(function(e){
str += "&"+this.name+'=false';
});
// Vars
var name = jQuery('#name').val();
var email = jQuery('#email').val();
var msg = jQuery('#msg').val();
var subj = jQuery('#subj').val();
validateEmail(email);
if (msg == '' || email == '' || validateEmail(jQuery('#email').val()) == false) {
validateEmail(email);
validateText(jQuery('#msg'));
validateText(jQuery('#name'));
return false;
}
jQuery.ajax({
type: "post",
url: ajaxactionurl,
data: "action=send_email&" + str + "&url=" + page_url,
dataType: 'json',
success: function (response) {
jQuery('#contact-form input').val('');
jQuery('#contact-form textarea').val('');
jQuery('.submit').text('Thank you!');
console.log(response.data);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus);
}
});
});
Your AJAX Call should only return JSON and should not return anything else, so making following changes.
$send_mail = mail($to, $subject, $message, $headers);
//echo $send_mail; Comment this, it is not required
if($send_mail) {
$data = get_field('success_message', 'option');
wp_send_json_success( array('data' => $data ) , 200); //Return as array.
}
//return $msg; Comment this as well.
die();
In your AJAX Callback of JS, you will get the data where you are using console.log(response.data);

Using expressmail with PHP form

We have a php script that emails form field values when a user submits the form. The form action points to the script below.
We've been asked to configure things to use expressmail explicitly. My question is, would this entail a modification to the script or is this a config setting on the server somewhere?
<?php
if (! $_POST) {
header('HTTP/1.0 405 Method Not Allowed');
exit;
}
$redirectTo = html_entity_decode($_POST['post']);
$body = '<html><body>';
$content = array();
foreach ($_POST as $key => $value) {
if ('-label' !== substr($key, -6)) {
continue;
}
$field = substr($key, 0, strlen($key) - 6);
$content[$field]['value'] = $_POST[$field];
$content[$field]['label'] = $_POST[$key];
}
$body .= '<h1>' . htmlentities($_POST['formName']) . '</h1>';
foreach ($content as $field => $value) {
$data = $value['value'];
$label = $value['label'];
$body .= '<p><b>' . htmlentities($label) . '</b><br />';
if (false === is_array($data) && (null === $data OR "" === trim($data))) {
$body .= 'N/A';
} elseif (is_array($data)) {
$body .= '<ul>';
foreach ($data as $val) {
$val = htmlentities($val);
$body .= '<li>' . $val . '</li>';
}
$body .= '</ul>';
} else {
$body .= htmlentities($data);
}
$body .= '</p>';
}
$body .= '</body></html>';
$to = strip_tags($_POST['emailTo']);
$subject = strip_tags($_POST['emailSubject']);
$headers = "From: " . strip_tags($_POST['emailFrom']) . "\r\n";
$headers .= "Reply-To: " . strip_tags($_POST['emailFrom']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to, $subject, $body, $headers);
header('Location: ' . $redirectTo);
?>

Not getting CSS with HTML Based Email In PHP?

I am trying to receive a loop based generated HTML Table in email but seems like I am getting email but no CSS embedded with it as I am passing the BootStrap library CSS files with the email but it's not getting any CSS at all..So I am wondering that what would be the problem...??
Here is screenshot as :
Here is my whole code as :
<?php
$message .= '<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">';
$message .= '<table class="table table-bordered">';
$message .= '<thead>';
$message .= '<tr>';
$message .= '<th>#</th>';
$message .= '<th>Username</th>';
$message .= '<th>Session From</th>';
$message .= '<th>Session Till</th>';
$message .= '<th>Uptime</th>';
$message .= '<th>Download</th>';
$message .= '<th>Upload</th>';
$message .= '<th>Total Usage</th>';
$message .= '</tr>';
$message .= '</thead>';
$message .= '<tbody>';
function human_filesize($bytes, $decimals = 2) {
$factor = floor((strlen($bytes) - 1) / 3);
if ($factor > 0) $sz = 'KMGT';
return sprintf("%.{$decimals}f ", $bytes / pow(1024, $factor)) . #$sz[$factor - 1] . 'B';
}
if (isset($_GET)) {
$user = $_GET["user"];
}
$x = 1;
$handle = fopen($user, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
$split_data = (explode(" ",$line));
if (in_array('customer=admin', $split_data)) {
foreach (array_values($split_data) as $i => $value) {
if (strpos($split_data[$i], 'user=') !== false) {
$username = explode("=", $split_data[$i]);
$username = $username[1];
}
}
foreach (array_values($split_data) as $i => $value) {
if (strpos($split_data[$i], 'from-time=') !== false) {
$from_time = explode("=", $split_data[$i]);
$from_time = $from_time[1];
$from_time = $from_time." ".$split_data[$i+1];
}
}
foreach (array_values($split_data) as $i => $value) {
if (strpos($split_data[$i], 'till-time=') !== false) {
$till_time = explode("=", $split_data[$i]);
$till_time = $till_time[1];
$till_time = $till_time." ".$split_data[$i+1];
}
}
foreach (array_values($split_data) as $i => $value) {
if (strpos($split_data[$i], 'uptime=') !== false) {
$uptime = explode("=", $split_data[$i]);
$uptime = $uptime[1];
$download = explode("=", $split_data[$i+1]);
$download = $download[1];
$upload = explode("=", $split_data[$i+2]);
$upload = $upload[1];
#$total_download += $download;
#$total_upload += $upload;
$total_usage = $total_download+$total_upload;
}
}
$message .= '<tr>';
$message .= '<th scope="row">'.$x.'</th>';
$message .= '<td>'.$username.'</td>';
$message .= '<td>'.$from_time.'</td>';
$message .= '<td>'.$till_time.'</td>';
$message .= '<td>'.$uptime.'</td>';
$message .= '<td>'.human_filesize($download,2).'</td>';
$message .= '<td>'.human_filesize($upload,2).'</td>';
$message .= '<td>'.human_filesize($total_usage,2).'</td>';
$message .= '</tr>';
$x=$x+1;
}
}
fclose($handle);
}
$message .= '</tbody>';
$message .= '</table>';
$to = 'nicefellow1234#gmail.com';
$subject = 'Website Change Reqest';
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to, $subject, $message, $headers);
?>
As of September 2016, Gmail accepts embedded styles – CSS within <style> tags in the head section of HTML documents.
This is in addition to inline styles, which were previously the only way to apply CSS in Gmail.
At the same time, Google says nothing about support for external styles, which is likely why your Bootstrap styles are failing to load.
https://developers.google.com/gmail/design/

form php attachment - specify which info I want to show in mail

I have this code that works good, but when i send it in the mail also appears things that I don't want that appears, for example:
submit = Enviar
recaptcha_challenge_field =
03AHJ_VuuCrxaVdxnIIg-Us7zrqZBDMBXeOuU21J60IblOCtFTQhMgtx-TsfsY6oHl5xbgdeqIRUQ7bTui
recaptcha_response_field = rsinmBlockquote
So I want to ask if there is a way of especify wich items I want to send something like:
$body="Contacto:
Nombre: " .$_POST["nombre"] . "\n
Empresa: " .$_POST["empresa"] . "\n
Ubicacion: " .$_POST["ubicacion"] . "\n
Telefono: " .$_POST["telefono"] . "\n
I'm not a programmer so I don't know how to put it into the actual code that is working:
function form_mail($sPara, $sAsunto, $sTexto, $sDe)
{
$bHayFicheros = 0;
$sCabeceraTexto = "";
$sAdjuntos = "";
if ($sDe)$sCabeceras = "From:".$sDe."\n";
else $sCabeceras = "";
$sCabeceras .= "MIME-version: 1.0\n";
foreach ($_POST as $sNombre => $sValor)
$sTexto = $sTexto."\n".$sNombre." = ".$sValor;
foreach ($_FILES as $vAdjunto)
{
if ($bHayFicheros == 0)
{
$bHayFicheros = 1;
$sCabeceras .= "Content-type: multipart/mixed;";
$sCabeceras .= "boundary=\"--_Separador-de-mensajes_--\"\n";
$sCabeceraTexto = "----_Separador-de-mensajes_--\n";
$sCabeceraTexto .= "Content-type: text/plain;charset=iso-8859-1\n";
$sCabeceraTexto .= "Content-transfer-encoding: 7BIT\n";
$sTexto = $sCabeceraTexto.$sTexto;
}
if ($vAdjunto["size"] > 0)
{
$sAdjuntos .= "\n\n----_Separador-de-mensajes_--\n";
$sAdjuntos .= "Content-type: ".$vAdjunto["type"].";name=\"".$vAdjunto["name"]."\"\n";;
$sAdjuntos .= "Content-Transfer-Encoding: BASE64\n";
$sAdjuntos .= "Content-disposition: attachment;filename=\"".$vAdjunto["name"]."\"\n\n";
$oFichero = fopen($vAdjunto["tmp_name"], 'r');
$sContenido = fread($oFichero, filesize($vAdjunto["tmp_name"]));
$sAdjuntos .= chunk_split(base64_encode($sContenido));
fclose($oFichero);
}
}
if ($bHayFicheros)
$sTexto .= $sAdjuntos."\n\n----_Separador-de-mensajes_----\n";
return(mail($sPara, $sAsunto, $sTexto, $sCabeceras, '-faltitux#altitux.mx'));
}
/* enviando correo */
if (form_mail("mymail#mail.com", $_POST[asunto],
"Los datos introducidos en el formulario son:\n\n", $_POST[email]))
$resultMenuUrlName = "bolsa_gracias.html";
echo "<META HTTP-EQUIV=Refresh CONTENT=0;URL=$resultMenuUrlName>";
} else {
echo "Lo sentimos pero no ha colocado el texto correctamente! Intente nuevamente...";
}
thx in advice and sorry for the bad english
this should work:
remove
foreach ($_POST as $sNombre => $sValor)
$sTexto = $sTexto."\n".$sNombre." = ".$sValor;
in the same spot add:
$sTexto="Contacto:
Nombre: " .$_POST["nombre"] . "\n
Empresa: " .$_POST["empresa"] . "\n
Ubicacion: " .$_POST["ubicacion"] . "\n
Telefono: " .$_POST["telefono"] . "\n

Send email according to input select value

I need to make changes to an existing form by adding a dropdown menu where I will have two inputs and their values. The purpose is to send the form to recipient_one if Address 1 is selected or to recipient_two when Address 2 is selected. Address 1 needs to be the default value when nothing is selected.
Here is just the added HTML:
<form method="post" action="./index.php" enctype="multipart/form-data">
<fieldset class="elist">
<legend>Select shop:</legend>
<select name="shop">
<option name="address-chosen" value="Tammsaare" >Tammsaare</option>
<option name="address-chosen" value="Ülemiste" >Ülemiste</option>
</select>
</fieldset>
</form>
and the PHP:
$action = isset($_POST['action']) ? $_POST['action'] : null;
$page = null;
$pages = array('info', 'en');
if( isset($_GET['page']) && in_array($_GET['page'], $pages) ) {
$page = $_GET['page'];
}
if( !in_array($page, $pages) ) {
$page = '';
}
$mail_sent = false;
if( $action == 'add' ) {
//Test if it is a shared client
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip = $_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
$message = '';
$message .= 'Name: '.safe($_POST['name'])."\r\n";
$message .= 'E-mail: '.safe($_POST['email'])."\r\n";
$message .= 'Phone: '.safe($_POST['telephone'])."\r\n";
$message .= 'Mark: '.safe($_POST['mark'])."\r\n";
$message .= 'Model: '.safe($_POST['model'])."\r\n";
$message .= 'Shop: '.safe($_POST['address-chosen'])."\r\n";
$message .= "Wants newsletter: ".$soovib_uudiskirja = isset($_POST['newsletter']) ? "Yes" : "No";
$message .= "\r\n";
$message .= "\r\n";
$message .= "\r\n";
$message .= 'Aeg: '.date('d.m.Y H:i')."\r\n";
$message .= 'IP: '.$ip."\r\n";
$mail_data = array(
'to_email' => 'email#mail.com',
'from_email' => 'email#mail.com',
'from_name' => 'Stock Cars',
'subject' => 'Reservation',
'message' => $message,
);
mail_send($mail_data);
$mail_sent = true;
}
function safe( $name ) {
return( str_ireplace(array( "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );
}
function mail_send($arr)
{
if (!isset($arr['to_email'], $arr['from_email'], $arr['subject'], $arr['message'])) {
throw new HelperException('mail(); not all parameters provided.');
}
$to = empty($arr['to_name']) ? $arr['to_email'] : '"' . mb_encode_mimeheader($arr['to_name']) . '" <' . $arr['to_email'] . '>';
$from = empty($arr['from_name']) ? $arr['from_email'] : '"' . mb_encode_mimeheader($arr['from_name']) . '" <' . $arr['from_email'] . '>';
$headers = array
(
'MIME-Version: 1.0',
'Content-Type: text/plain; charset="UTF-8";',
'Content-Transfer-Encoding: 7bit',
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
'Message-ID: <' . $_SERVER['REQUEST_TIME'] . md5($_SERVER['REQUEST_TIME']) . '#' . $_SERVER['SERVER_NAME'] . '>',
'From: ' . $from,
'Reply-To: ' . $from,
'Return-Path: ' . $from,
'X-Mailer: PHP v' . phpversion(),
'X-Originating-IP: ' . $_SERVER['SERVER_ADDR'],
);
mail($to, '=?UTF-8?B?' . base64_encode($arr['subject']) . '?=', $arr['message'], implode("\n", $headers));}
if (isset($_GET['page'])) {}
So the question is how do I reconstruct the array?
Set the email variable based on the form value:
//default is email 1
$email='email#mail.com';
if(isset($_POST['shop']) && $_POST['shop']=='Ülemiste') {$email='email2#mail2.com';}
$mail_data = array(
'to_email' => $email,
'from_email' => $email,
'from_name' => 'Stock cars',
'subject' => 'Reservation',
'message' => $message,
);
edited as per your edit - not sure how the umlaut will effect things though

Categories