Sending HTML form by php, receiving empty email But I am still receiving empty mail. What is wrong? Sorry I am beginner. I have a simple email form in a php file and i try to send emails but it seems that my variables come null. I have an echo after my code just to test if my variables have any values inside and they are not printed. The only thing that is printed is the 'done' and the 'email $to'. Do i do anything wrong? I followed this method from a post in youtube and he did the exact same thing and it worked for him. I also tried more email php files but still nothing. Here is my html and php code.
Thanks a lot.
<?
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 .= " - ".$item_15." <br>";
if($item_16)$body .= " - ".$item_16." <br>";
if($item_17)$body .= " - ".$item_17." <br>";
if($item_18)$body .= " - ".$item_18." <br>";
if($item_19)$body .= " - ".$item_19." <br>";
if($item_20)$body .= " - ".$item_20." <br>";
if($item_21)$body .= " - ".$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))."?=
"; //제목
$mailContent = $form_area_inquiry;
$mailHeader = "From: $mailFrom
";
$mailHeader .= "MIME-Version: 1.0
";
$mailHeader .= "Content-type: text/html; charset=utf-8
";
$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>
second file
<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>