我有一個插件在我的wordpress網站上,它允許自定義PHP。 我創建了一個EMail表單,但是當涉及到發送時,它的錯誤。 當我發送表單完全空,它的工作原理,但只要我填寫1個字段,它給了我一個404錯誤...我試了POST和GET,但都是相同的結果。 這是我的代碼:(請不要介意,荷蘭文XD)WordPress的PHP POST/GET方法
$name = $_POST['name'];
$email = $_POST['email'];
$age = $_POST['age'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$ip = $_SERVER['REMOTE_ADDR'];
$issent = $_POST['issent'];
if(!$name) {$errorcount++; $error['name'] = "<text style='color:red;'>Voer je naam in A.U.B.</text><br>";}
if(!$email) {$errorcount++; $error['email'] = "<text style='color:red;'>Voer een E-Mail in A.U.B.</text><br>";}
if(!$age) {$errorcount++; $error['age'] = "<text style='color:red;'>Voer je leeftijd in A.U.B.</text><br>";}
if(!$subject) {$errorcount++; $error['subject'] = "<text style='color:red;'>Voer een onderwerp in A.U.B.</text><br>";}
if(!$message) {$errorcount++; $error['message'] = "<text style='color:red;'>Voer een bericht in A.U.B.</text><br>";}
if($errorcount > 0 || !isset($issent)){
//Error display
if(isset($issent)){
echo $error['name'];
echo $error['email'];
echo $error['age'];
echo $error['subject'];
echo $error['message'];
}
?>
<form method="POST" action="">
<label>Naam: </label><input type="text" name="name" value="<?php echo$name; ?>"><br>
<label>E-Mail: </label><input type="email" name="email" value="<?php echo$email; ?>"><br>
<label>Leeftijd: </label><input type="text" name="age" value="<?php echo$age; ?>"><br>
<label>Onderwerp: </label><input type="text" name="subject" value="<?php echo$subject; ?>"><br>
<label>Bericht: </label><br>
<textarea rows="15" cols="40" name="message"><?php echo$message; ?></textarea><br>
<input type="hidden" value="1" name="issent">
<input type="submit">
</form>
<?php
} else {
$to = "Myemail";
$headers = 'From: [email protected]' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Return-Path: Myemail' . "\r\n";
$headers .= 'Reply-To: ' . $email . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();;
$finalmsg = "<h1>".$subject."</h1><br><br>";
$finalmsg .= "Naam: ".$name."<br>";
$finalmsg .= "E-Mail: ".$email."<br>";
$finalmsg .= "Leeftijd: ".$age."<br>";
$finalmsg .= "Onderwerp: ".$subject."<br>";
$finalmsg .= "IP: ".$ip."<br>";
$finalmsg .= "Bericht: <br>".$message."<br>";
mail($to,"JKC Mail Form: ".$subject,$finalmsg,$headers);
echo "E-Mail verstuurd! <br>Wij nemen Z.S.M. contact met u op!";
}
我似乎沒有得到它的工作... 有人可以幫我,我已經一派閃人,但我沒有能夠修復它。
WordPress的寄存器,捕獲和行爲。您的字段名稱很常見,可能會與其中的一個或多個相沖突。我會用一些獨特的名稱空間爲所有變量加前綴,例如:'$ _POST ['so24138113_name'']' – cpilko