【发布时间】:2016-09-27 08:17:28
【问题描述】:
我正在使用 php 脚本提交表单并将其发送到特定的电子邮件地址,这一切正常。
但对于我的移动版本和桌面版本,我使用不同的脚本,因为标头位置重定向具有不同的输出。
但是,当我点击移动版本上的发送按钮时,它仍然会将我重定向到我的桌面版本的输出。
Desktop output = homepage.html
Mobile output = index.html
有什么想法吗?
sn-ps 中的代码
/* 桌面 PHP */
<?php $Naam=$_POST['Naam'];
$Email=$_POST['Email'];
$Telefoon=$_POST['Telefoon'];
$Bericht=$_POST['Bericht'];
$to="info@pieterswebdesign.com";
$subject="pieterswebdesign";
$body="this is an automated message don't reply to this email \n\n $Naam,$Email,$Telefoon,$Bericht";
mail($to,
$subject,
$body);
header('Location: homepage.html');
?>
/*移动 PHP */
<?php $Naam=$_POST['Naam'];
$Email=$_POST['Email'];
$Telefoon=$_POST['Telefoon'];
$Particulier=$_POST['Particulier'];
$Contacteermij=$_POST['Contacteermij'];
$Bericht=$_POST['Bericht'];
$to="info@pieterswebdesign.com";
$subject="pieterswebdesign";
$body="this is an automated message don't reply to this email \n\n $Naam,$Email,$Telefoon,$Particulier,$Contacteermij,$Bericht";
mail($to,
$subject,
$body);
header('Location: index.html');
?>
/* 桌面表单 */
<div id="wrappercontactform">
<div id="emptydivform"></div>
<p id="formcontacthead">CONTACT FORM</p>
<form id="contactform" class="form" action="send.php" method="POST">
<p class="name">
Naam
<input type="text" name="Naam" id="name" placeholder="Typ hier..." />
</p>
<p class="email">
E-mail adres
<input type="text" name="Email" id="email" placeholder="Typ hier..." />
</p>
<p class="telefoonnummer">
Telefoonnummer
<input type="text" name="Telefoon" id="telefoonnummer" placeholder="Typ hier..." />
</p>
<p class="bericht">
Bericht
<textarea type="text" name="Bericht" id="bericht" placeholder="Typ hier..." /></textarea>
</p>
<button class="submit" input type="submit" form="contactform">Verstuur</button>
</form>
/* 移动表单 */
<form id="contactform" class="form" action="sendmobile.php" method="POST">
<p class="name">
Naam
<input type="text" name="Naam" id="name" placeholder="Typ hier..." />
</p>
<p class="email">
E-mail adres
<input type="text" name="Email" id="email" placeholder="Typ hier..." />
</p>
<p class="telefoonnummer">
Telefoonnummer
<input type="text" name="Telefoon" id="telefoonnummer" placeholder="Typ hier..." />
</p>
<p class="particulier">
Particulier, zakelijk, vereniging...
<input type="text" name="Particulier" id="particulier" placeholder="Typ hier..." />
</p>
<p class="contacteermij">
Contacteer mij op (bv: datum & uur)
<input type="text" name="contacteermij" id="contacteermij" placeholder="Typ hier..." />
</p>
<p class="bericht">
Uw vraag / bericht
<textarea type="text" name="Bericht" id="bericht" placeholder="Typ hier..." /></textarea>
</p>
<button class="submit" input type="submit" form="contactform">Verstuur</button>
</form>
【问题讨论】:
-
是什么决定了是加载移动端代码还是桌面端代码?您是否检查过它是否有效?
-
可能您正在为移动设备和桌面呈现相同的表单?由于表单操作,它会将表单数据发送到桌面版本
-
我在 index.html 上使用媒体查询,移动版本应该完美地重定向到这些工作,您可以在 www.pieterswebdesign.com/desktop/index.html 进行检查
-
您是如何分离 PC 和移动表单的?正如许多人所建议的那样,它可能只是使用 PC。
-
最可能的原因是您的手机上显示的是“桌面”表单,您确定显示的是正确的表单吗?
标签: php redirect header location