我已经创建了一个与我联系的'表单,我试图发送电子邮件到特定的电子邮件地址。但是,我不喜欢服务器端编程,我得到一个未定义的索引/变量错误,我似乎无法解决。你能否指出这个错误。
错误:
注意:未定义的索引:在第4行的C:\ xampp \ htdocs \ unnamed \ upload.php中提交
HTML代码
<form action="upload.php" method="post" style="height:100%">
<input name="articleTitle" value="Title" maxlength="50"
id="articleTitle">
<textarea name="article-body">
Compose your article...
</textarea>
<script>
CKEDITOR.inline( 'article-body' );
</script>
<br>
<input name="senderName" type="text" value="Name" maxlength="50"
id="name" class="textBox">
<input name="senderEmail" value="Email address" maxlength="50"
id="email" class="textBox">
<input name="abtyou" value="About Yourself" maxlength="150"
id="abtyou" class="textBox">
<input type="submit" name="submit" class="button">
</form>
PHP代码
<?php
if($_POST["submit"]) {
$recipient="zain.farid@live.com";
$subject="New Guest Post";
$sender=$_POST["senderName"];
$senderEmail=$_POST["senderEmail"];
$senderAbout=$_POST["abtyou"];
$message=$_POST["article-body"];
$title=$_POST["articleTitle"];
$mailBody="Name: $sender\nEmail: $senderEmail\nAbout Sender: $senderAbout\nTitle: $title\n\n$message";
mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
$thankYou="<p>Thank you! Your post has been submitted.</p>";
}
?>
谢谢。
答案 0 :(得分:1)
如果设置为isset()
像这样:
if(isset($_POST["submit"]))