2014-11-06 214 views
0

我已經設置了<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 = '[email protected]'; 

$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

你的意思是在同一個窗口彈出?我猜這是一個html元素,看起來像一個彈出,或者你已經有另一個contact.html彈出,你想更新? – Arie 2014-11-06 21:11:14

回答

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  = '[email protected]'; 

$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; } ?> 
相關問題