There is a send.php page on it accepting an array of a post, and sending a letter to an email, and immediately redirects to the header ("location: here is the main page"); and everything seems to be good! But before going to the main page, for some reason it shows the contents of the sent letter on the send.php page. and there are no conclusions on it. What is the problem tell me?

Here is the code:

header ('Content-type: text/html; charset=windows-1251'); $email_to = '4up@mail.ru'; $name = $_POST['fio']; $email = $_POST['email']; $phone = $_POST['phone']; if($_POST['count']){ $count = $_POST['count']; } else{ $count = 'не заполнено'; } if($_POST['rayon']){ $rayon = $_POST['rayon']; } else{ $rayon = 'не заполнено'; } if($_POST['date']){ $date = $_POST['date']; } else{ $date = 'не заполнено'; } if($_POST['price']){ $price = $_POST['price']; } else{ $price = 'не заполнено'; } $type_deal = $_POST['type_check']; $type_real_estate = $_POST['type_check2']; $message = $_POST['comm']; $message = "Имя : " . $name . "\r\n email : " . $email . "\r\n Телефон : " . $phone . "\r\n тип сделки : " . $type_deal . "\r\n Тип недвижимости : " . $type_real_estate ."\r\n количество комнат : ".$count."\r\n В районе : ".$rayon."\r\n Сроки сдачи : ".$date."\r\n Ориентировачная стоимость : ".$price."\r\n текст сообщения : " . $message; $headers = "From: $email\r\n"; $headers .= "Reply-To: $email\r\n"; mail('4up@mail.ru',$headers,$message); header("Главная страница"); 
  • @adun, To format a code, select it with the mouse and click on the {} button of the editor. - Artem
  • why should I format the code?) - adun
  • Firstly, there is no bitrix and does not smell, and secondly, it either redirects or shows !!! It cannot be otherwise. Most likely you will not be redirected anywhere. - binliz

1 answer 1

Perhaps this is due to the fact that at the beginning of the page is specified

 header ('Content-type: text/html; charset=windows-1251'); 

those. you indicate that the output of the current page is text

  • did not solve the problem, closed access. Thanks for the answer, I tried to “reward”. It seemed to work, I hope I didn’t do anything bad :) - adun