dpylt7626401 2013-04-04 02:45
浏览 49

初学者PHP邮件功能问题+服务器错误

So I'm a super beginner to PHP, but I'm currently building my first website and I wanted to have a contact form on the site that a user can fill out, and then have their information be sent to an email.

So I wrote the PHP for this using the "mail()" function, but for some reason whenever the user hits submit, it just goes to a page with the code on it and not the page I linked it to in the echo statement.

Here's my PHP:

<?php 
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent="From: $name 
 Phone: $phone 
 Message: $message";
$recipient = "rowan.krishnan@tufts.edu";
$subject = "Contact Form";
$mailheader = "From: $email 
";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
$url = 'contact.html';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'  
?>

And here's my html:

<div id="emailform">
   <form action="mail.php" method="POST">
       Name: <input type="text" name="name">
       Email: <input type="text" name="email">
       Phone: <input type="text" name="phone">
       Message: <textarea name="message" rows="6" cols="25"></textarea><br />
       <input type="submit" value="Send"><input type="reset" value="Clear">
   </form>
</div>

My final problem is related to the web server/host that I use (hostgator). For some reason, whenever I upload any documents that contain PHP in them, I get a 500 Internal Server Error and I'm not really sure what's going on there. If any of you know what I'm talking about, it would be great if you had advice.

Thanks so much for reading all this and helping out.

  • 写回答

3条回答 默认 最新

  • doumu6997 2013-04-04 02:53
    关注

    You are missing a ; at the end of your echo which is most likely causing the white page

     echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
                                                               ^
    

    try checking your errorlogs to see what errors you have been getting and try turning on error messages

    also the message needs to have for each line

    $formcontent="From: $name 
     Phone: $phone 
     Message: $message";
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向