doujia4759 2014-03-20 21:19
浏览 17
已采纳

PHP形式射击空白

My PHP form is sending me blank emails.

I'm not sure where the issue is and wondered if anyone would be kind enough to help out.

Here's the HTML

                <div class="form">
            <form method="post" action="send_contact.php">
                <div class="form_row">
                <label>Your Name:</label>
                <input type="text" name="name" class="main_input" />
                </div>

                <div class="form_row">
                <label>Your Email:</label>
                <input type="text" name="email" class="main_input" />
                </div>
                <div class="form_row">
                <label>Type of Inquiry:</label>
                <input type="text" name="inquiry" class="main_input" />
                </div>  

                <div class="form_row">
                <label>Your Message:</label>
                <textarea name="message" class="main_textarea"></textarea>
                </div> 

                <div class="form_row">
                 <input type="submit" class="submit" value="Submit" >
                </div>
            </div>
            </form>
         </div>

Here's the PHP

<?php

$subject = "$inquiry";

$message = "$message";


$mail_from = "$email";

$header = "from: $name <$mail_from>";

// Enter your email address
$to ='inquiries@openrhythmnetwork.com';

$send_contact = mail($to,$subject,$message,$header);

// Check, if message sent to your email 
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

Literally, all I'm receiving is a blank email with no subject heading...

  • 写回答

4条回答 默认 最新

  • douchongbang6011 2014-03-20 21:36
    关注

    The following has been tested and working on my server. PHP Version 5.4

    PHP (send_contact.php)

    <?php
    $name = $_POST['name'];
    $subject = $_POST['inquiry'];
    $message = $_POST['message'];
    $mail_from = $_POST['email'];
    
    $header = "From: $name <$mail_from>";
    
    // Enter your email address
    $to ='email@example.com'; // change to your Email address
    
    $send_contact = mail($to,$subject,$message,$header);
    
    // Check, if message sent to your email 
    // display message "We've received your information"
    if($send_contact){
    echo "We've received your contact information";
    }
    else {
    echo "ERROR";
    }
    ?>
    

    HTML form:

        <div class="form">
    <form method="post" action="send_contact.php">
        <div class="form_row">
        <label>Your Name:</label>
        <input type="text" name="name" class="main_input" />
        </div>
    
        <div class="form_row">
        <label>Your Email:</label>
        <input type="text" name="email" class="main_input" />
        </div>
        <div class="form_row">
        <label>Type of Inquiry:</label>
        <input type="text" name="inquiry" class="main_input" />
        </div>  
    
        <div class="form_row">
        <label>Your Message:</label>
        <textarea name="message" class="main_textarea"></textarea>
        </div> 
    
        <div class="form_row">
         <input type="submit" class="submit" value="Submit" >
        </div>
    </div>
    </form>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?