M
M
Mikhailushka2018-11-09 01:30:10
PHP
Mikhailushka, 2018-11-09 01:30:10

Why is only the first word from select sent when sending a message to the mail?

Hello!
I send the form to the mail via ajax request, from the field where the select is located (for example, there is "Additional education") only the first word is sent. Before submitting, the entire text is displayed in the form itself.
Here is the select code

<?php 
                  $program = mysqli_query($conn, "SELECT * FROM `program`");

                        while($prog = mysqli_fetch_assoc($program))
                        {
                          echo "<option value=$prog[name_program]>$prog[name_program]</option>";
                        }

                  ?>

Here is the handler code
<meta charset="UTF-8">
<?php
  // Записываем в переменны
  $fname = htmlspecialchars($_POST ['fname']);
  $lname = htmlspecialchars($_POST ['lname']);
  $sname = htmlspecialchars($_POST ['sname']);
  $org = htmlspecialchars($_POST ['org']);
  $phone = htmlspecialchars($_POST ['phone']);
  $email = htmlspecialchars($_POST ['email']);
  $message = htmlspecialchars($_POST ['message']);
  $specialty = htmlspecialchars($_POST ['specialty']);

  /*if ($fname == '') {
    echo 'Заполните все поля';	
    exit;
  }*/
  // Отправка 
 $subject1= "=?utf-8?B?".base64_encode($subject1)."?=";
 $subject2= "=?utf-8?B?".base64_encode($subject2)."?=";

/* получатели */
$to1= "<[email protected]>" . ", " ; 
$to2= "$email" . ", " ; //Дополнительный email 
/* тема/subject */
$subject1 = "Студен записался";
$subject2 = "Вы записались";

/* сообщение */
$message1 = '
<html>
<head>
 <title>Тестовое сообщение</title>
</head>
<body>
<p><b>Какая то информация по пользователю</p></b>
<table>
<tr>
<b>Фамилия:</b> '.$lname.'<br>
</tr>
<tr>
<b>Имя:</b> '.$fname.'<br>
</tr>
<tr>
<b>Отчество:</b> '.$sname.'<br>
</tr>
<tr>
<b>Город:</b> '.$org.'<br>
</tr>
<tr>
<b>Телефон:</b> '.$phone.'<br>
</tr>
<tr>
<b>Почта:</b> '.$email.'<br>
</tr>
<tr>
<b>Вопросы:</b> '.$message.'<br>
</tr>
<tr>
<b>Программа:</b> '.$specialty.'<br>
</tr>
</table>
</body>
</html>
';

$message2 = '
<html>
<head>
 <title>Тестовое сообщение</title>
</head>
<body>
<tr>
Здравствуйте, вы записались на:<br>
</tr>
<tr>
<b>Специальность:</b> '.$specialty.'<br>
</tr>
</table>
</body>
</html>
';
/* Шапки */
$headers1= "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=UTF-8\r\n";
$headers2= "MIME-Version: 1.0\r\n";
$headers2 .= "Content-type: text/html; charset=UTF-8\r\n";

/* дополнительные шапки */
/*$fname= "=?utf-8?B?".base64_encode($fname)."?=";
$lname= "=?utf-8?B?".base64_encode($lname)."?=";*/
$flname = $fname . ' ' . $lname;
$headers1 .= "From: $flname <$email>\r\n";
$headers2 .= "From: [email protected]\r\n";

/* и теперь отправим из */
if (mail($to1, "=?UTF-8?B?".base64_encode($subject1)."?=", $message1, $headers1))
  $done = "Сообщение отпрвленоa";
if (mail($to2, "=?UTF-8?B?".base64_encode($subject2)."?=", $message2, $headers2))
  echo '<div class=footer_form mb>'.$done.'</div>';
else 
   echo "Сообщение не отправлено";
  ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Softer, 2018-11-09
@noire_night

echo "<option value=\"$prog[name_program]\">$prog[name_program]</option>";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question