2014-02-28 167 views
3


我似乎有一个电子邮件表单的问题,我正在做。
表单正常工作,直到我添加了一些额外的部分。但是,即使我评论我的更改,它也不起作用。
我认为这个问题可能是由于某些语法错误造成的,但似乎并非如此。
我没有得到任何错误信息如下
是我的代码:
php邮件表单不发送邮件

<?php 
if(isset($_REQUEST['email'])) { 
    $num=$_REQUEST['num']; 
    $desc=$_REQUEST['desc']; 
    $subject="einak"; 
    $nomr=$_REQUEST['nomr']; 
    $sphr=$_REQUEST['sphr']; 
    $cylr=$_REQUEST['cylr']; 
    $angr=$_REQUEST['angr']; 
    $addr=$_REQUEST['addr']; 
    $diar=$_REQUEST['diar']; 
    $noml=$_REQUEST['noml']; 
    $sphl=$_REQUEST['sphl']; 
    $cyll=$_REQUEST['cyll']; 
    $angl=$_REQUEST['angl']; 
    $addl=$_REQUEST['addl']; 
    $dial=$_REQUEST['dial']; 
    $type=$_REQUEST['type']; 
    $matter=$_REQUEST['matter']; 
    $color=$_REQUEST['color']; 
    $message=$num."<br />".$nomr."<br/>".$sphr."<br/>".$cylr."<br/>".$angr."<br />".$addr."<br />".$diar."<br />"."<br />".$noml."<br/>".$sphl."<br/>".$cyll."<br/>".$angl."<br />".$addl."<br />".$dial."<br />".$desc."<br />".$type."<br />".$matter."<br />".$color."<br />"; 
    $email='[email protected]'; 
    $headers='MIME-Version: 1.0'."\r\n"; 
    $headers.='Content-type: text/html; charset=iso-8859-1'."\r\n"; 
    mail("[email protected]",$subject,$message,$headers); 
    echo "ارسال شما موفقیت آمیز بود"; 
} else { 
    echo "<form method='post'> 
       <input name='num' id='num' type='text' /> <br /> 
       <input type='text' name='nomr' id='nomr' > <br /> 
       <input type='text' name='sphr' id='sphr'> <br /> 
       <input type='text' name='cylr' id='cylr' > <br /> 
       <input type='text' name='angr' id='angr' > <br /> 
       <input type='text' name='addr' id='addr' > <br /> 
       <input type='text' name='diar' id='diar' > <br /> 
       <input type='text' name='noml' id='noml' > <br /> 
       <input type='text' name='sphl' id='sphl'> <br /> 
       <input type='text' name='cyll' id='cyll' > <br /> 
       <input type='text' name='angl' id='angl' > <br /> 
       <input type='text' name='addl' id='addl' > <br /> 
       <input type='text' name='dial' id='dial' > <br /> 
       <textarea id='desc' name='desc'> </textarea>   
       <input name='type' type='radio' value='bifocal' id='type1' /> 
       <input name='type' type='radio' value='progres' id='type2' /> 
       <input name='type' type='radio' value='single' id='type3' /> 
       <input name='type' type='radio' value='decen' id='type4' /> 
       <input name='matter' type='radio' value='glass' id='mat1' /> 
       <input name='matter' type='radio' value='plastic' id='mat2' /> 
       <input name='color' type='radio' value='single' id='col1' /> 
       <input name='color' type='radio' value='decen' id='col2' /> 
       <input type='submit' id='sb' value='ارسال اطلاعات' /> 
       <input type='text' name='name' id='name' > <br /> 
       <input type='add' name='address' id='address' > <br /> 
      </form > 
      <p id='confirmation'></p> 
      <input type='submit' id='vis' onClick='vis(); return false;' value='تایید اطلاعات'/>"; 
} 
?> 
+0

如果您使用安全服务器尝试发送邮件时获取哪条错误消息,那么您需要将有效邮件从选项中传递 –

+0

我认为你不会选择任何一个单选按钮 –

+0

问题是,我没有得到任何错误信息 – soheils

回答

9

你还没有在这里提交按钮定义名称

<input type='submit' id='sb' name='email' value='ارسال اطلاعات' /> 

您正在检查的代码if(isset($_REQUEST['email']))并没有电子邮件领域我看到的形式。

基本上这个检查用于验证表单是否已经提交(通常是其他的)。因此,您需要在提交按钮属性中添加name='email'以执行if条件代码。

+1

谢谢你!!!!!这是问题所在 – soheils

1

你设置一个MIME头,但你没有设置任何MIME编码,这可能是一个问题;-) 尝试使用专用包,如PEAR/Mail(和PEAR/Mail/Mime)或phpMailer

<input type='submit' id='sb' value='ارسال اطلاعات' /> 

替换上面的代码与下面的代码: