【问题标题】:How to popup in the same window?如何在同一个窗口中弹出?
【发布时间】:2014-11-06 21:06:26
【问题描述】:

我已经设置了<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;

【问题讨论】:

  • 在同一个窗口中弹出窗口是什么意思?我猜它要么是一个看起来像弹出窗口的 html 元素,要么您已经有另一个用于contact.html 的弹出窗口,您想更新它?

标签: php forms popup contact


【解决方案1】:

我不确定您为什么要使用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; } ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-12
    • 2019-04-14
    • 1970-01-01
    相关资源
    最近更新 更多