2016-06-21 111 views
0

我一直在使用公司擴展名單。唯一不起作用的是管理員在擴展列表中的表單上添加新用戶時,我希望它通過電子郵件將表單詳細信息發送給我的老闆,這樣每次有人添加他都知道。php郵件正文問題

我讀了一點,因爲我很新的PHP,但我發現這個mailto html命令,它很好地把主題行和正確的電子郵件地址,但身體看起來很可怕。所有混合起來是這樣的:

name:jurgen&extension number:242&email:[email protected]&mode=added 

我讀到了關於PHP腳本的電子郵件,但我很困惑如何做到這一點。有人能告訴我一種方法來實現這一點嗎?我希望第一個按鈕發送電子郵件,然後必須顯示第二個按鈕以將數據添加到數據庫中。

我當前的代碼:

<form name="form1" action="<?=$_SERVER['PHP_SELF'];?>?mode=added" method="post"> 
<div align="center"><table class="searchable"> 
<tr><td>Extension:</td><td><div align="center"> 
<input type="text" name="ext" required /> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Name:</td><td><div align="center"> 
<input type="text" name="name" required /> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Department:</td><td><div align="center"><select name="department" required> 
      <option value="VW NEW CARS ADMIN AND STOCK CONTROL">Value 4</option> 
      <option value="value 5">value 5</option> 
      <option value="value 6">value 6</option> 
      <option value="value 3">value 3</option> 
      <option value="value 4">value 4</option> 
    </select> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Email:</td><td><div align="center"> 
<input type="text" name="email" pattern="[a-z0-9._%+-][email protected][a-z0-9.-]+\.[a-z]{2,3}$" name="email" title="Example: [email protected]" required/> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Cellphone:</td><td><div align="center"> 
<input type="text" name="phone" /> 
</div></td></tr> 
<tr><td colspan="2" align="center">| <button type="submit" formaction="mailto:[email protected]?subject=New User Added To Extension List" enctype="text/plain" method="get">Email Boss</button> 
<tr><td colspan="2" align="center"><a href="javascript:history.go(-1);">Back</a> | <input type="submit" name="submit" id="submit" value="Add New Contact"<?php if($disable ==1){?>disabled<?php } ?>/></td></tr> 
<input type="hidden" name="mode" value="added"> 
+0

請添加您的嘗試並編輯您的問題。 – limonik

+0

你的問題到底是什麼? – Gideon

+0

@limonik編輯先生 – 5ilent

回答

1

如果你想在你的電子郵件使用HTML建立了良好的機身設計, 例如:

        $to = $email; 
           $message = " 
           <table width='100%' border='0' cellspacing='0' cellpadding='3'> 
            <tr> 
            <td colspan=2><b>SignalShare</b></td> 
            </tr> 
            <tr> 
            <td colspan=2>Thank you for creating an account.</td> 
            </tr> 
            </table> 
            <hr><h3>Account info</h3><hr> 
            <table width='100%' border='0' cellspacing='0' cellpadding='3'> 
            <tr> 
            <td width='28%' >Username : </td> 
            <td width='72%'>".$username."</td> 
            </tr> 
            <tr> 
            <td>Email : </td> 
            <td>".$email."</td> 
            </tr> 
           </table> 
           <p>SignalChat advise you not to delete this email for it contains informations that could be in use later.</p> 
            <hr><h3>Account activation</h3><hr> 
            <p>If you wish to activate your account please use the following link : </p> 
            <p><a href = 'localhost/SignalShare/activate.php?code=$code&user=$username' style = 'text-decoration: none; color: blue;' >Activate account</a></p> 
            <hr> 
            <p>If this email does not concern you please ignore it.</p> 
            <p>All regards.</p> 
            <p>SignalShare.</p> 
            "; 
           $subject = "Accout activation";         
           $headers = "From: SignaShare\r\n"; 
           $headers .= "Content-type: text/html\r\n"; 

           mail($to, $subject, $message, $headers);   
           header("Location: success.php?email=".$email.""); 

正如你可以看到我使用的表和html標籤來幫助整理電子郵件,並且如果您在$標頭中注意到我添加了$ header。=「Content-type:text/html \ r \ n」;
如果這不是你所要求的,請在這裏留言,所以我可以編輯我的答案,祝你好運