Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP显示引导模式?_Php_Jquery_Html_Twitter Bootstrap_Modal Dialog - Fatal编程技术网

如何使用PHP显示引导模式?

如何使用PHP显示引导模式?,php,jquery,html,twitter-bootstrap,modal-dialog,Php,Jquery,Html,Twitter Bootstrap,Modal Dialog,我不认为我的标题能公正地回答这个问题,但它可能会让人困惑,我不想把标题延伸到几行 下面是: 我有一个单页网站,该网站有一个带有以下代码的联系表: <form class="move-down" name="contactform" method="post" action="contact-form-handler.php"> <div class="controls controls-row"> <input id="name" name="name" type=

我不认为我的标题能公正地回答这个问题,但它可能会让人困惑,我不想把标题延伸到几行

下面是:

我有一个单页网站,该网站有一个带有以下代码的联系表:

<form class="move-down" name="contactform" method="post" action="contact-form-handler.php">
<div class="controls controls-row">
<input id="name" name="name" type="text" class="span3" placeholder="Name"> 
<input id="email" name="email" type="email" class="span3" placeholder="Email address">
</div>
<div class="controls">
<textarea id="message" name="message" class="span6" placeholder="Your Message" rows="7"></textarea>
</div>
<div class="controls pull-right">
<button id="contact-submit" type="submit" class="btn btn-default">Send it!</button>
</div>
</form>

发送它!
如您所见,其操作是调用名为“contact form handler”的外部php文件,如下所示:

<?php
$errors = '';
$myemail = 'hello@wunderful.co.uk';//<-----Put Your email address here.
if(empty($_POST['name'])  ||
   empty($_POST['email']) ||
   empty($_POST['message']))
{
    $errors .= die(header('Location: #errorModal'));
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
    $errors .= die(header('Location: #errorModal'));
}

if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email_address\n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' modal
header('Location: #thanksModal');
}
?>

<?php
?>

这一直运作良好,但由于我的新网站是一个页面,我不想单独加载页面,也不想在白色背景上回显黑色文本

所以我的问题是-当单击submit按钮时,如何显示引导模式窗口,并使用外部文件中的php代码,而不重新加载页面


我希望能做到。如果不能,请有人帮我启动一个模式,在单击提交按钮时显示错误或感谢?

可以。因为您没有使用oop方式,所以可以这样做

1) 在提交页面上,您将分配一些
$mail\u send=true发送电子邮件后

2) 您可以在此处填写并说出模态代码

3) 删除此
标题('Location:#thanksModal')您不需要它

Put
$mail\u send=true而不是那个


仅此而已。

我认为您应该使用jQuery AJAX