2013-06-27 104 views
0

這個問題我已經通過電子郵件發送,如何發送密碼鏈接到用戶的電子郵件,當用戶點擊忘記密碼鏈接....發送密碼鏈接到時用戶忘記密碼

這裏是ForgetPasswordViewController.php ...我開發本作只是呈現出警報...... 不過來實時的時候..我不知道如何發送密碼鏈接..用戶電子郵件...

<?php 


     header("Cache-Control: private, must-revalidate, max-age=0"); 
     header("Pragma: no-cache"); 
     header("Expires: Fri, 4 Jun 2010 12:00:00 GMT"); 

//如果未提交表格HTML將直接顯示

  if (!isset($_POST['submit'])) 
      { 
    ?> 
     <html> 
     <body> 

     <form name='f1' method="POST" action="" onSubmit="return ValidateEmail();">  
     <div id="fp"> 
     <span style="margin-left:-50px">Email:</span>&nbsp;&nbsp; 
     <span><input class="input" type="text" name="Email" placeholder="Enter mailID" required></span><br> 
     <input style="height:50px; width:120px; background:url(Images/submit_butto.gif) no-repeat right top; border: none;" type="submit" name="submit" value=""> 
     <?PHP 
     } 
     else 
     { 
     $Email=$_POST['Email']; 
     if(!empty($Email)) 
     { 
     $model = new UsersModel(); 
     $rowsCount = $model->checkUserEmail($Email); 
      echo $rowsCount; 
     if ($rowsCount!=0) 
     { 
//If you are submitting the form insert the details into database 
     echo '<script type="text/javascript">alert("A password hasbeen sent to your Email.."); 
     window.location.href="LoginViewController.php";</script>'; 
    } 
    else 
     { 
    echo'<script type="text/javascript">alert("Enter valid email"); 
     window.location.href="ForgetPasswordViewController.php";</script>'; 
     } 

     } 
     } 
     ?> 
    </body> 
    </html> 

任何建議是可以接受的....

+0

具體是什麼問題,簡單的教程?你不知道如何創建鏈接?你不知道如何發送電子郵件? – deceze

+0

@deceze問題我不知道如何發送電子郵件... –

+1

只是一個額外的有趣閱讀: http://stackoverflow.com/a/1069799/1063823 – Duikboot

回答

2

使用,如果你想發送的電子郵件驗證碼:

$to  = '[email protected]'; 
$subject = 'Subject here'; 
$message = "Content"; 
$message .= "more Content"; 
$message .= "even more Content or a variable".$variable; 
$headers = 'From: [email protected]' . "\r\n" . 
'Reply-To: [email protected]' . "\r\n" . 
'X-Mailer: PHP/' . phpversion(); 
mail($to, $subject, $message, $headers); 

要知道,有安全問題,如頭注入,如果你不驗證用戶輸入。一個好的電子郵件驗證是這樣的:

$to = $_POST["email"]; 
if (filter_var($email, FILTER_VALIDATE_EMAIL)) { /*mail is ok*/ } 
else {/*mail is NOT ok*/} 
+1

行..謝謝你它的工作... –

+0

太棒了,不客氣!請接受答案... – Sergio

1

可以使用PHPMailer

發送郵件下面是PHPMailer

How to send mail using PHP

+0

感謝您的快速回復... –

+0

如果你喜歡這個答案,那麼你可以接受或投票答案 –

+1

但是對於投票需要一些聲望點...我沒有...那些。我已經接受了塞爾吉奧的回答...... –