当点击提交时,url更改为我的php脚本位置



所以我用php编写了一个简单的联系表单,当我点击提交按钮时,它在桌面上的chrome上运行代码很好,但当我在移动浏览器上(有时在桌面上(点击提交时,它会出错,url会更改为脚本的位置,但它仍然提交了一封电子邮件,但当它出错时,它被踢回垃圾邮件。当它真的起作用时,我的联系表格看起来很好。有人能发现我遗漏的一个明显问题吗?

<div class="contact_form">
<form class="contact_form" action="contactform2.php" method="post">
<input type="text" name="name" placeholder="Full Name..." required>
<input type="tel" name="phone" placeholder="Phone Number..." required>
<input type="email" name="email" placeholder="Email..." required>
<input type="text" name="subject" placeholder="Subject..." required>
<textarea id="message" name="message" rows="10" cols="56" placeholder="Message..." required></textarea>
<button type="submit" name="submit">Submit</button>
</form>
</div>
<?php
if (isset($_POST['submit'])) {
require('phpmailer/PHPMailerAutoload.php');
$mail = new PHPmailer;
$mail->Host='';
$mail->Port=587;
$mail->SMTPAuth=true;
$mail->SMTPSecure='tls';
$mail->Username='';
$mail->Password='';

$mail->Setfrom($_POST['email'],$_POST['name']);
$mail->addAddress('');
$mail->addAddress('');
$mail->addReplyTo($_POST['email'],$_POST['name']);

$mail->isHTML(true);
$mail->Subject=''.$_POST['subject'];
$mail->Body='<h3 align=left>Name: '.$_POST['name'].'<br><br>Email: '.$_POST['email'].'<br><br>Telephone: '.$_POST['phone'].'<br><br>Message: '.$_POST['message'].'</h3>';

if(!$mail->send()) {
$result="Something went wrong Please try again.";
}
else {
header("Location: mail_sent.html");
}
}
?>

if(isset($_POST[‘submit’](

这是用于检查submit参数是否存在的代码。

最新更新