dscc90150010 2013-07-24 21:54
浏览 37
已采纳

联系表格php麻烦

This is the code i use, when i input information into the form the mail sends incomplete emails like if i add 1 to all fields and email name etc it shows:

From:
Email:
Tale:
Sms:
Data:
Levrandør:
Ekstra informasjon:

So im lacking the information.

 <?php 

   $name = $_POST['f_name'];
   $email = $_POST['email'];
   $tale = $_POST['tale'];
   $sms = $_POST['sms'];
   $data = $_POST['data'];
   $levrandor = $_POST['levrandor'];
   $ekstra = $_POST['ekstra'];
   $formcontent="From: $name 
 Email: $email 
 Tale: $tale 
 Sms: $sms 
 Data: $data 
 Levrandør: $levrandor 
 Ekstra informasjon: $ekstra";
   $recipient = "post@mobilavtalen.no";
   $subject = "Melding fra bruker.";
   $mailheader = "From: $email 
";

   mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");

   if(mail){

   header('Location: thanks.html');

   }else{ echo "Email ble ikke sendt";}


    ?>

HTML form:

<div class="form_area text-left">
            <form id="contact-form" action="mail.php" method="post">
                <fieldset>
                    <label>Navn:</label>
                    <input type="text" placeholder="">
                    <label>E-mail: (Må fylles inn)</label>
                    <input type="email" placeholder="" required>
                    <label>Forbruk pr mnd (Må fylles inn):</label>
                    <label>Tale:</label>
                    <input type="text" placeholder="" required>
                    <label>Sms:</label>
                    <input type="text" placeholder="" required>
                    <label>Data:</label>
                    <input type="text" placeholder="" required>
                    <label>Levrandør:</label>
                    <input type="text" placeholder="" required>
                    <label>Ekstra informasjon:</label>
                    <textarea rows="3"></textarea><br>
                    <!--<input type="submit" id="submit_button" class="btn" value="Send">-->
                    <button name="submit" type="submit" id="submit_button">Send</button>
              </fieldset>
            </form>
        </div>
  • 写回答

1条回答 默认 最新

  • doushen9863 2013-07-24 22:10
    关注

    You need to set the name property on the form fields.

    The name property should be the same as the key you use in the $_POST array. Like this for example:

    <input type="text" name="f_name" placeholder="">
    

    And in PHP

    $name = $_POST['f_name'];
    

    You can read more about the $_POST array here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图