在后台运行php文件(PHPMailer通过gmail发送电子邮件),并在发送电子邮件时在同一页面发出警报
我正在使用PHPMailer将gmail帐户中的电子邮件发送到index.html页面上提交表单中的电子邮件。这个很好用。但由于我实际使用的是send.php文件,因此send.php页面会在表单提交后出现。我想留在index.html页面上,让send.php在后台工作,并在发送电子邮件时在index.html页面上发出警报 注意:这里没有SQL/任何数据库作业。我正在使用send.php中的PHPMailer从我的gmail向表单中提交gmail id的用户发送电子邮件在后台运行php文件(PHPMailer通过gmail发送电子邮件),并在发送电子邮件时在同一页面发出警报,php,html,forms,phpmailer,Php,Html,Forms,Phpmailer,我正在使用PHPMailer将gmail帐户中的电子邮件发送到index.html页面上提交表单中的电子邮件。这个很好用。但由于我实际使用的是send.php文件,因此send.php页面会在表单提交后出现。我想留在index.html页面上,让send.php在后台工作,并在发送电子邮件时在index.html页面上发出警报 注意:这里没有SQL/任何数据库作业。我正在使用send.php中的PHPMailer从我的gmail向表单中提交gmail id的用户发送电子邮件 <fo
<form action="send.php" class="form" id="frm-js" method="POST">
<div class="form__group">
<input type="text" class="form__input" id="name" name="name" placeholder="Full Name" required>
<label for="name" class="form__label">Full Name</label>
</div>
<div class="form__group">
<input type="text" class="form__input" id="email" name="email" placeholder="Email Address" required>
<label for="email" class="form__label">Email Address</label>
</div>
<div class="form__group">
<input type="text" class="form__input" id="phone" name="phone" placeholder="Phone Number">
<label for="phone" class="form__label">Phone Number</label>
</div>
<div class="form__group">
<textarea id="message" rows="4" cols="50" name="message" class="textarea-frm form__input" maxlength="1000" placeholder="Your message"></textarea>
</div>
<div class="form__group">
<button class="btn" type="submit" name="submit">Book</button>
</div>
</form>
全名
电子邮件地址
电话号码
书
谢谢您可以使用jquery尝试一下,从表单标签中删除操作,我添加了一个
p
来显示来自send.php
<form class="form" id="frm-js" method="POST">
<p id="resp_msg"></p>
<div class="form__group">
<input type="text" class="form__input" id="name" name="name" placeholder="Full Name" required>
<label for="name" class="form__label">Full Name</label>
</div>
<div class="form__group">
<input type="text" class="form__input" id="email" name="email" placeholder="Email Address" required>
<label for="email" class="form__label">Email Address</label>
</div>
<div class="form__group">
<input type="text" class="form__input" id="phone" name="phone" placeholder="Phone Number">
<label for="phone" class="form__label">Phone Number</label>
</div>
<div class="form__group">
<textarea id="message" rows="4" cols="50" name="message" class="textarea-frm form__input" maxlength="1000" placeholder="Your message"></textarea>
</div>
<div class="form__group">
<button class="btn" type="submit" name="submit">Book</button>
</div>
</form>
这是send.php,应该是这样的
if(isset($_POST['data'])) {
$params = array();
parse_str($_POST['data'], $params);
//send mail
echo "Hi, " . $params['name'] . " your email has sended";
}
我不想在同一页上显示成功或失败。我正在使用警报。谢谢你的回复
if(isset($_POST['data'])) {
$params = array();
parse_str($_POST['data'], $params);
//send mail
echo "Hi, " . $params['name'] . " your email has sended";
}