2011-09-21 119 views
2

我開發了一個php電子郵件激活碼,用於在註冊後激活用戶的帳戶,我想要的是如果用戶第一次單擊激活鏈接後,鏈接將被禁用,任何人都可以提供幫助,非常感謝! 這裏是我的PHP代碼:如何在第一次點擊後禁用電子郵件鏈接

$to = $email; 
    $subject = " Your Registration"; 
    $message = "Welcome to our website!\r\rThanks for completing registration at www.example.com. 
    You can complete registration by clicking the following link:\rhttp://www.example.com/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ www.example.com Team"; 
    $headers = 'From: [email protected] example.com' . "\r\n" . 

'Reply-To: [email protected] example.com' . "\r\n" . 

'X-Mailer: PHP/' . phpversion(); 

mail($to, $subject, $message, $headers); 
+0

您需要一個唯一的,可識別的字段值('key','activateid'等)來驗證請求,然後您需要存儲一個值,該值顯示帳戶已激活,然後在激活中進行檢查.php代碼來確保它尚未被使用。 –

回答

2

您需要保存activation code到數據庫中,每當他/她請求激活,比較請求激活代碼針對數據庫,如果它是有效的,那麼你必須remove那個activation code剛好在你爲該賬號設置了confirm參數之後。

+0

謝謝,我的意思是有一種方法來防止鏈接功能,以便當我點擊那個eamil鏈接它將無法正常工作。 – tony

相關問題