PHP 电子邮件表单问题
我之前使用过这个网站并取得了巨大的成功,但我在使用 php 电子邮件表单时也遇到了类似的问题。我试图从以前的表格中复制该网站上的人员对按照我想要的方式工作非常有帮助,但由于某种原因,它不会发送该表格。我确信这是一个愚蠢的疏忽,但希望能有第二双眼睛。
这是代码:
<?php
$state = 0;
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("[email protected]", 'Website Inquiry: '.$subject, "\n".$comments."
\n\n".$name."\n\n".$company."\n\n".$email."\n\n".$_SERVER['REMOTE_ADDR']."\n\n".'InterestedIn: '.$InterestedIn, "\n\n".'ContactMethod: '.$ContactMethod,"From: $email");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
$state = 2;
} else if(isset($message) and $message!=""){
// if verification code was incorrect then return to contact page and show error
$state = 1;
}
if ($state == 0) { ?>
<form action="" method="post" name="form1" id="form1"
onsubmit="MM_validateForm('email','','RisEmail','name','','R','verif_box','','R')
;return document.MM_returnValue">
<p><strong>Tell us what you're interested in:</strong></p>
<dl>
<dd><input type="radio" name="InterestedIn" value="BIBS<?php echo $_GET['InterestedIn'];?>"> Blow-In-Blanket System
<input type="radio" name="InterestedIn" value="Foam<?php echo $_GET['InterestedIn'];?>"> Soya Spray Foam
<input type="radio" name="InterestedIn" value="Attic<?php echo $_GET['InterestedIn'];?>"> Attic Insulation
<input type="radio" name="InterestedIn" value="NotSure<?php echo $_GET['InterestedIn'];?>" checked="checked"> Not Sure</dd>
</dl>
<p><strong>Enter additional comments in the space provided below:</strong></p>
<dl>
<dd><textarea name="comments" cols="50" rows="5" border="0" id="comments"><?php echo $_GET['comments'];?></textarea></dd>
</dl>
<p><strong>Tell us how to get in touch with you:</strong></p>
<dl>
<dd>
<table>
<tr>
<td>Name*</td>
<td>
<input type="text" size="40" maxlength="256" name="Name" value="<?php echo $_GET['name'];?>"></td>
</tr>
<tr>
<td>Company</td>
<td>
<input type="text" size="40" maxlength="256" name="Company" value="<?php echo $_GET['company'];?>"></td>
</tr>
<tr>
<td>Email*</td>
<td><input type="text" size="40" maxlength="256" name="email" value="<?php echo $_GET['email'];?>"></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" size="40" maxlength="256" name="Phone" value="<?php echo $_GET['phone'];?>"></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" size="40" maxlength="256" name="City" value="<?php echo $_GET['city'];?>"></td>
</tr>
</table>
</dd>
</dl>
<p><strong>Best method to get in touch with you:</strong></p>
<dl>
<dd><input type="radio" name="ContactMethod" value="byphone<?php echo $_GET['InterestedIn'];?>" checked="checked"> Phone
<input type="radio" name="ContactMethod" value="byemail<?php echo $_GET['InterestedIn'];?>"> Email
</dd>
</dl>
<dl><dd><img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="top"/> <input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:80px; height:14px;"/><br /><br />
Enter Verification Image
</dd></dl>
<p style="padding-left:60px;"><input type="submit" class="button primary" value="Submit Form" name="submit"/>
<input type="reset" class="button primary" value="Clear Form" name"clear" /></p>
</form>
任何帮助将不胜感激,因为我家里有一个新婴儿,作为新妈妈,我的时间非常紧迫,并试图完成最后一个项目。
先感谢您!
I have used this site before with great success and I am having a similar issue with a php email form. I tried to copy from the previous form that the guys on this site were extremely helpful in getting to work the way I wanted, but for some reason or another it won't send the form. I am sure that it is a silly oversight, but would appreciate a second set of eyes.
Here is the code:
<?php
$state = 0;
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("[email protected]", 'Website Inquiry: '.$subject, "\n".$comments."
\n\n".$name."\n\n".$company."\n\n".$email."\n\n".$_SERVER['REMOTE_ADDR']."\n\n".'InterestedIn: '.$InterestedIn, "\n\n".'ContactMethod: '.$ContactMethod,"From: $email");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
$state = 2;
} else if(isset($message) and $message!=""){
// if verification code was incorrect then return to contact page and show error
$state = 1;
}
if ($state == 0) { ?>
<form action="" method="post" name="form1" id="form1"
onsubmit="MM_validateForm('email','','RisEmail','name','','R','verif_box','','R')
;return document.MM_returnValue">
<p><strong>Tell us what you're interested in:</strong></p>
<dl>
<dd><input type="radio" name="InterestedIn" value="BIBS<?php echo $_GET['InterestedIn'];?>"> Blow-In-Blanket System
<input type="radio" name="InterestedIn" value="Foam<?php echo $_GET['InterestedIn'];?>"> Soya Spray Foam
<input type="radio" name="InterestedIn" value="Attic<?php echo $_GET['InterestedIn'];?>"> Attic Insulation
<input type="radio" name="InterestedIn" value="NotSure<?php echo $_GET['InterestedIn'];?>" checked="checked"> Not Sure</dd>
</dl>
<p><strong>Enter additional comments in the space provided below:</strong></p>
<dl>
<dd><textarea name="comments" cols="50" rows="5" border="0" id="comments"><?php echo $_GET['comments'];?></textarea></dd>
</dl>
<p><strong>Tell us how to get in touch with you:</strong></p>
<dl>
<dd>
<table>
<tr>
<td>Name*</td>
<td>
<input type="text" size="40" maxlength="256" name="Name" value="<?php echo $_GET['name'];?>"></td>
</tr>
<tr>
<td>Company</td>
<td>
<input type="text" size="40" maxlength="256" name="Company" value="<?php echo $_GET['company'];?>"></td>
</tr>
<tr>
<td>Email*</td>
<td><input type="text" size="40" maxlength="256" name="email" value="<?php echo $_GET['email'];?>"></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" size="40" maxlength="256" name="Phone" value="<?php echo $_GET['phone'];?>"></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" size="40" maxlength="256" name="City" value="<?php echo $_GET['city'];?>"></td>
</tr>
</table>
</dd>
</dl>
<p><strong>Best method to get in touch with you:</strong></p>
<dl>
<dd><input type="radio" name="ContactMethod" value="byphone<?php echo $_GET['InterestedIn'];?>" checked="checked"> Phone
<input type="radio" name="ContactMethod" value="byemail<?php echo $_GET['InterestedIn'];?>"> Email
</dd>
</dl>
<dl><dd><img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="top"/> <input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:80px; height:14px;"/><br /><br />
Enter Verification Image
</dd></dl>
<p style="padding-left:60px;"><input type="submit" class="button primary" value="Submit Form" name="submit"/>
<input type="reset" class="button primary" value="Clear Form" name"clear" /></p>
</form>
Any help would be appreciated as I have a new baby at home and am very pressed for time being a new mom and trying to get this last project completed.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为一些基本的调试会有很大帮助。
您似乎正在混合
$_GET
和method='post'
尝试使用单行脚本,仅使用硬编码值调用
mail()
。这有效吗?尝试提交您的表单。输出
$_POST
。它有你所期待的一切吗?$_COOKIE
吗?提前构建您要传递到
mail
的所有字符串。它们看起来都像应该的那样吗?尝试获取这些确切的字符串并将它们直接放入
mail()
中(如上面的#2)。这有效吗?当您读完此列表时,您就会知道故障出在哪里,并且可以获得更具体的答案。
I think some basic debugging would help a lot.
You seem to be mixing
$_GET
and amethod='post'
Try a one line script that just does a call to
mail()
with hardcoded values. Does that work?Try submitting your form. Output
$_POST
. Does it have everything you were expecting? Does$_COOKIE
?Construct all the strings you are passing into
mail
ahead of time. Do they each look like they are supposed to?Try taking those exact strings and putting them into
mail()
directly (like #2 above). Does that work?By the time you get to the end of this list, you'll know where the failure is and can get a much more specific answer.