通过php发送HTML表单,接收空电子邮件

时间:2016-08-09 01:13:45

标签: php email

通过php发送HTML表单,接收空电子邮件 但我仍然收到空邮件。怎么了?对不起,我是初学者。 我在php文件中有一个简单的电子邮件表单,我尝试发送电子邮件,但似乎我的变量为空。我的代码后面有一个回声,只是为了测试我的变量里面是否有任何值而且它们没有被打印出来。唯一印刷的是'完成'和'电子邮件$ to'。我做错了吗?我从youtube上的一个帖子中跟踪了这个方法,他完成了同样的事情并且对他有用。我也尝试了更多的电子邮件php文件,但仍然没有。这是我的HTML和PHP代码。

非常感谢。

<?
include_once $_SERVER[DOCUMENT_ROOT]."/include/initiate.php";
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
//메뉴1
$sql = "SELECT mu_name FROM prd_menu1 where idx='$menu1'";
$result = mysql_query($sql) or error(mysql_error());
$menu1_view = mysql_fetch_array($result);
//메뉴2
$sql = "SELECT mu_name FROM prd_menu2 where idx='$menu2'";
$result = mysql_query($sql) or error(mysql_error());
$menu2_view = mysql_fetch_array($result);


$body = "";
$body .= $item_1."<hr>";
$body .= "1) Operating Frequency Range(MHz)  : Start (".$item_2.") / Stop (".$item_3.")  <br><br>";
$body .= "2) Gain(dB)  : ".$item_4."  <br><br>";
$body .= "3) Total Output Power(dBm)  : ".$item_5."  <br><br>";
$body .= "4) What is the input source for an amplifier?  : ".$item_6."  <br><br>";
$body .= "5) Total Output Power(dBm)  : ".$item_7." (".$item_8.") / ".$item_9." (".$item_10.") / ".$item_11." (".$item_12.")  <br><br>";
$body .= "6) Supply Voltage(Vdc)  : ".$item_13."  <br><br>";
$body .= "7) Current Consumption(mA)  : ".$item_14."  <br><br>";
$body .= "8) Additional Functions (If you need additional function like the below, please check)  : <br>";
if($item_15)$body .= "&nbsp;&nbsp; - ".$item_15." <br>";
if($item_16)$body .= "&nbsp;&nbsp; - ".$item_16." <br>";
if($item_17)$body .= "&nbsp;&nbsp; - ".$item_17." <br>";
if($item_18)$body .= "&nbsp;&nbsp; - ".$item_18." <br>";
if($item_19)$body .= "&nbsp;&nbsp; - ".$item_19." <br>";
if($item_20)$body .= "&nbsp;&nbsp; - ".$item_20." <br>";
if($item_21)$body .= "&nbsp;&nbsp; - ".$item_21." <br>";
$body .= "<br>9) Other Comments  : <br>";
$body .= $item_22."  <br>";

$form_title=$menu1_view[mu_name]." > ".$menu2_view[mu_name]." > Name : ".$WriterName;
$user_name=$WriterName;
$user_email=$Email;
$user_tel=$WriterTel;
$body.="
<hr>
date : ".date("Y-m-d H:i:s")." <br>
Name : $WriterName  <br>
Company Name : $CompanyName <br>
E-Mail : $Email <br>
Tel : $WriterTel <br>
Your comment : <br>
".nl2br($comments)." ";

$sql = "
        insert into prd_form_data set
            form_type = '2',
            form_title = '".$form_title."',
            user_name = '".$WriterName."',
            user_email = '".$Email."',
            user_tel = '".$WriterTel."',
            user_content = '".$body."',
            insdt = now()
";
mysql_query($sql) or error(mysql_error());

/*
$form_area_inquiry = "회사명 : $CompanyName <br>
작성자명 : $WriterName <br>
이메일 : $Email <br>
전화번호 : $WriterTel <br>
내용 : ".$body." <br>
";
*/

$mailTo     =   ADMIN_MAIL; // 받는 메일 주소;
$mailFrom   =   "test@echomicrowave.com";   //  

$mailSubject = "=?EUC-KR?B?".base64_encode(iconv("UTF-8","EUC-KR",$form_title))."?=\r\n"; //제목

$mailContent = $form_area_inquiry;

$mailHeader = "From: $mailFrom\r\n";
$mailHeader .= "MIME-Version: 1.0\r\n";
$mailHeader .= "Content-type: text/html; charset=utf-8\r\n";

$mailResult = mail ($mailTo, $mailSubject, $mailContent, $mailHeader,'-f'.$mailFrom);
?>

<form method="post" action="<?=$url?>" name="frm">
</form>

<script type="text/javascript">
<!--
    alert ("Thank you for your contact.");
    document.frm.submit();
//-->
</script>

第二档

                    <h2 class="tit"><?=$view[prd_name]?></h2>

<?if(!$editmode){?>
        <form id="usrform" name="usrform" action="inquiry2.proc.php"  method="post">
        <input type="hidden" name="url" value="<?=$_SERVER['REQUEST_URI']?>" />
        <input type="hidden" name="prod_title" value="<?=$view[prd_name]?>" />
        <input type="hidden" name="menu1" value="<?=$menu1?>" />
        <input type="hidden" name="menu2" value="<?=$menu2?>" />
<?}?>
                    <div class="tempListBox">
                        <div class="temptit">
                            <p><input type="checkbox" name="item_1" value="High Power Amplifiers" /> High Power Amplifiers</p>
                            <p><input type="checkbox" name="item_1" value="Linear Power Amplifiers" /> Linear Power Amplifiers</p>
                        </div>
                        <ol class="tempListwrap">
                            <li>
                                <p class="tempstit"><span>1</span>Operating Frequency Range(MHz)</p>
                                <div class="tempList">
                                    <p>Start <input type="text" name="item_2" /></p>
                                    <p>Stop <input type="text" name="item_3" /></p>
                                </div>
                            </li>
                            <li>
                                <p class="tempstit"><span>2</span>Gain(dB) <input type="text"  name="item_4" /></p>
                            </li>
                            <li>
                                <p class="tempstit"><span>3</span>Total Output Power(dBm) <input type="text"  name="item_5" /></p>
                            </li>
                            <li>
                                <p class="tempstit"><span>4</span>What is the input source for an amplifier? <em>ex) TETRA, GSM, CDMA, UMTS, LTE etc</em></p>
                                <div class="tempList">
                                    <input type="text"  name="item_6" />
                                </div>
                            </li>
                            <li>
                                <p class="tempstit"><span>5</span>Total Output Power(dBm)</p>
                                <div class="tempList">
                                    <div class="temp_half">
                                        <p><input type="checkbox"  name="item_7" value="IP3(CW 2 Tone, Channel Spacing 100KHz)" /> IP3(CW 2 Tone, Channel Spacing 100KHz)</p>
                                        <span class="tempimg"><img src="images/temp4_1.jpg" alt="" /></span>
                                        <input type="text" name="item_8"  />
                                    </div>
                                    <div class="temp_half">
                                        <p><input type="checkbox" name="item_9" value="P1dB(dBm)" /> P1dB(dBm)</p>
                                        <span class="tempimg"><img src="images/temp4_2.jpg" alt="" /></span>
                                        <input type="text" name="item_10" />
                                    </div>
                                    <div>
                                        <p><input type="checkbox" name="item_11" value="If you need additional request, please let me know." /> If you need additional request, please let me know. Ex) ACLR, ACRR, Squrious Emission, 2nd harmonic etc.</p>
                                        <input type="text" name="item_12" />
                                    </div>
                                </div>
                            </li>
                            <li>
                                <p class="tempstit"><span>6</span>Supply Voltage(Vdc) <input type="text" name="item_13" /></p>
                            </li>
                            <li>
                                <p class="tempstit"><span>7</span>Current Consumption(mA) <input type="text" name="item_14" /></p>
                            </li>
                            <li>
                                <p class="tempstit"><span>8</span>Additional Functions (If you need additional function like the below, please check)</p>
                                <div class="tempList">
                                    <p><input type="checkbox" name="item_15" value="Monitoring Port" /> Monitoring Port</p>
                                    <p><input type="checkbox" name="item_16" value="Gain Adjustable(0~30dB / 1dB step / DIP Switch)" /> Gain Adjustable(0~30dB / 1dB step / DIP Switch)</p>
                                    <p><input type="checkbox" name="item_17" value="ALC Function" /> ALC Function</p>
                                    <p><input type="checkbox" name="item_18" value="AMP On / Off function" /> AMP On / Off function</p>
                                    <p><input type="checkbox" name="item_19" value="Output Power Detection" /> Output Power Detection</p>
                                    <p><input type="checkbox" name="item_20" value="Back Power Detection" /> Back Power Detection</p>
                                    <p><input type="checkbox" name="item_21" value="Over power Shutdown (Auto Shutdown)" /> Over power Shutdown (Auto Shutdown)</p>
                                </div>
                            </li>
                            <li>
                                <p class="tempstit"><span>9</span>Other Comments</p>
                                <div class="tempList">
                                    <textarea name="item_22" id="item_22"></textarea>
                                </div>
                            </li>
                        </ol>
                    </div>

                    <div class="tempRedbox">
                        <p class="redtit">CONTACT INFO</p>
                        <ul>
                            <li><span>Company Name</span> <input type="text" name="CompanyName" id="CompanyName" /></li>
                            <li><span>Email</span> <input type="text" name="Email"  id="Email"/></li>
                            <li><span>Name</span> <input type="text" name="WriterName" id="WriterName" /></li>
                            <li><span>Tel</span> <input type="text" name="WriterTel" id="WriterTel" /></li>
                            <li class="full"><span>Comments</span> <textarea name="comments" id="comments"></textarea></li>
                        </ul>
                    </div>
                    <div class="btns">
                        <a href="javascript:;" class="tb_btns" onclick="CheckSubmit(this)"><span class="bt_submit" >Submit</span></a>
                        <a href="javascript:;" class="tb_btns" onclick="document.usrform.reset();"><span class="bt_clear">Clear Form</span></a>
                    </div>

<script type="text/javascript">
<!--
    function CheckSubmit(){
        var f = document.usrform;

        if(f.WriterName.value == ""){
            alert("Your Name.");
            return false;
        }
        if(f.Email.value == ""){
            alert("Your Email.");
            return false;
        }

        if (f.Email.value.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) {
           alert("Required to email."); 
           return false;
        }

        if(f.CompanyName.value == ""){
            alert("Your Company.");
            return false;
        }
        if(f.comments.value == ""){
            alert("Content input.");
            return false;
        }
        f.submit();
    }
//-->
</script>

1 个答案:

答案 0 :(得分:0)

你评论了$form_area_inquiry。这导致它是空的。

改变这个:

/*
$form_area_inquiry = "회사명 : $CompanyName <br>
작성자명 : $WriterName <br>
이메일 : $Email <br>
전화번호 : $WriterTel <br>
내용 : ".$body." <br>
";
*/

到此:

$form_area_inquiry = "회사명 : $CompanyName <br>
작성자명 : $WriterName <br>
이메일 : $Email <br>
전화번호 : $WriterTel <br>
내용 : ".$body." <br>
";