Как всплыть в том же окне?

Я установил <form action="sendemail.php">, Код ниже написан в sendemail.php,
Проблема в том, что я хочу, чтобы сообщение о статусе появлялось в том же окне, скажем contact.html, Он не должен открывать новое окно, которое говорит:

«Спасибо, что связались с нами. Как можно раньше мы свяжемся с вами»

Это появляется в новом пустом окне с этим сообщением ^^^^,


header('Content-type: application/json');
$status = ("Thank you for contacting us. As early as possible  we will contact you");$name        = @trim(stripslashes($_POST['name']));
$email       = @trim(stripslashes($_POST['email']));
$product_id  = @trim(stripslashes($_POST['product_id']));
$phonenumber = @trim(stripslashes($_POST['phonenumber']));
$quantity    = @trim(stripslashes($_POST['quantity']));
$subject     = @trim(stripslashes($_POST['subject']));
$message     = @trim(stripslashes($_POST['message']));

$email_from = $email;
$email_to = 'xyz@gmail.com';

$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Product Id: ' . $product_id . "\n\n" . 'Contact Number: ' . $phonenumber . "\n\n" .'Quantity: ' . $quantity . "\n\n" .'Subject: ' . $subject . "\n\n" . 'Complete Address: ' . $message ."\n\n";

$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die;

0

Решение

Я не уверен, почему вы делаете jSON, но если jSON не требуется:

<?php
$name           =   @trim(stripslashes($_POST['name']));
$email          =   @trim(stripslashes($_POST['email']));
$product_id     =   @trim(stripslashes($_POST['product_id']));
$phonenumber    =   @trim(stripslashes($_POST['phonenumber']));
$quantity       =   @trim(stripslashes($_POST['quantity']));
$subject        =   @trim(stripslashes($_POST['subject']));
$message        =   @trim(stripslashes($_POST['message']));

$email_from     =   $email;
$email_to       =   'xyz@gmail.com';

$body           =   'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Product Id: ' . $product_id . "\n\n" . 'Contact Number: ' . $phonenumber . "\n\n" .'Quantity: ' . $quantity . "\n\n" .'Subject: ' . $subject . "\n\n" . 'Complete Address: ' . $message ."\n\n";

// If main processes successfully, then continue with message
if(@mail($email_to, $subject, $body, 'From: <'.$email_from.'>')) { ?>
<!-- Just write normally -->
Thank you for contacting us. As early as possible  we will contact you.
<?php die; } ?>
0

Другие решения

Других решений пока нет …