K
K
Kirill2016-01-27 18:11:46
PHP
Kirill, 2016-01-27 18:11:46

How to enter email into mail?

Hello! It is necessary for me that the letter came to the client who entered email into a DB. I wrote the code, the form of the return letter, and inserted the variable that is entered into the printf recipient, it does not work, what is the error?

<html>
    <head>
        <meta charset=utf-8>
        </head>
    </html>
<?php
    if (isset($_POST["submit"])) {
        $firstname = $_POST["firstname"];
        $email10 = $_POST["email10"];
        $tel10 = $_POST["tel10"];
         $mes10 = $_POST["mes10"];
        $to= require 'cmsadmin/connect.php';

$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
$row = mysql_fetch_array($result);


do
{
  printf("" .$row['email5'] . "");


}
  



while($row = mysql_fetch_array($result));; //Ваша почта (куда будут приходить письма)
        $message = "
        $firstname \n
        $email10 \n
        $tel10 \n
        $mes10 \n
        ";
        //Этот текст Вам придет
        
        if ($email10 != 0) { //проверка, ввиден ли email, если да - добавляем в письмо и его
            $message .= "\n e-mail: $email10";
        }
$from  = "From: 24goldsite <24goldsite.ru>\r\nReply-To: [email protected]";
mail($to , "Запрос на домен" , $message , $from) or die("Ошибка в отправке письма");
        print "Запрос получен, в течении двух часов, мы с Вами свяжемся";
    }
?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Pavlenko, 2016-01-27
@RichyNix

you have an error in your while loop

R
Ruslan, 2016-01-28
@Gavr23

Is there an email5 field in the database?
Why do you need mysql_fetch_array twice?
Why use the do...while construct?
could do that

$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
$row = mysql_fetch_array($result);
print_r($row);

We output an array and see what the request returned to us, and then we send mail.

S
Sergey, 2016-01-29
@gangstarcj

Administrator, please ban this person. He asks the same question 4 times already and every time he is not satisfied with the answers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question