2014-02-28 163 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='ارسال اطلاعات' /> 

替換上面的代碼與下面的代碼: