douzhechi2435 2018-01-06 09:57
浏览 37

HTML表单到PHP邮件无法正常工作[重复]

This question already has an answer here:

I am absolutely bad at PHP programming. I have no experience with it, but I wanted a form on my website with a mail script. So like almost every other person with no experience on a language, I googled up one and customized it.

mail_send.php

<?php 
if(isset($_POST['submit'])){
$to = "my@mailadress.com"; // I just did this for privacy     
$from = $_POST['email'];     
$name = $_POST['name'];    
$subject = "Form submission";    
$message = $name . " " . $from . " wrote the following:" . "

" . 
$_POST['message'];    

$headers = "From:" . $from;    
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
}
?>

and here the HTML code: index.html

 <form role="form" id="feedbackForm" class="text-center" action="mail_send.php" method="post">
          <div class="form-group">
            <label for="name">Naam</label>
            <input type="text" class="form-control" id="name" name="name" placeholder="Name">
            <span class="help-block" style="display: none;">Voer uw naam in..</span></div>
          <div class="form-group">
            <label for="email">E-Mail</label>
            <input type="email" class="form-control" id="email" name="email" placeholder="Email Address">
            <span class="help-block" style="display: none;">Voer een geldig e-mailadres in.</span></div>
          <div class="form-group">
            <label for="message">Bericht</label>
            <textarea rows="10" cols="100" class="form-control" id="message" name="message" placeholder="Message"></textarea>
            <span class="help-block" style="display: none;">Voer een bericht in.</span></div>
          <button type="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
        </form>

So I have uploaded both files to my Website Server so I've tested it online, but still without success. Any smart guys being able to help me?

Thanks in advance :)

</div>
  • 写回答

4条回答 默认 最新

  • dongou5100 2018-01-06 10:30
    关注

    Please modify button tag

    <button type="submit"  name="submit" id="feedbackSubmit" class="btn btn-primary btn-lg" style=" margin-top: 10px;"> Verstuur</button>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用