我的网站sayus重定向太多,当您尝试提交要通过电子邮件发送的表单时,就会发生这种情况。两者之间的联系是正确的。
表单代码:
<section class="linksMain">
<div class="form-style-5">
<form action="../php/main/contact1.php" method="post">
<fieldset>
<legend>Personelijke informatie</legend>
<input class="form" type="text" name="field1" placeholder="Je naam *">
<input class="form" type="email" name="field2" placeholder="Je email *">
<input class="form" type="text" name="field3" placeholder="Onderwerp">
<label for="job">Categorie</label>
<select id="job" name="field4">
<option value="School">School</option>
<option value="Stage">Stage</option>
<option value="Media">Media INN</option>
<option value="Copt">Copyright</option>
<option value="Opdracht">Opdracht</option>
<option value="Opdracht">VKG</option>
<option value="Opdracht">Privé</option>
<option value="other_indoor">Anders</option>
</optgroup>
</select>
</fieldset>
<fieldset>
<legend>Bericht</legend>
<textarea class="form" name="field5" placeholder="Over jezelf"></textarea>
</fieldset>
<input type="submit" value="Verstuur" />
</form>
</div>
</section>
PHP代码:
#This sends emails to [email protected], the filler of the email comes from a form in main/contact.php
$name = $POST['field1'];
$email = $POST['field2'];
$subject = $POST['field3'];
$category = $POST['field4'];
$message = $POST['field5'];
$mailTo = "[email protected]";
$headers = "From:".$mailFrom;
$txt = "Je hebt een email gekregen van".$name.".\n\n".$message;
mail($mailTo, $subject, $category, $headers);
header("Location: contact1.php?mailsend");
要更改为header("Location: contact1.php?mailsend");
的标题位置将触发重定向。等等。您必须捕获?mailsend
查询,并检查是否传递以停止代码。
if ($_GET['mailsend'] == false) {
mail($mailTo, $subject, $category, $headers);
header("Location: contact1.php?mailsend");
}