2013-04-09 141 views
-3

訪問,這可能是不可能的,但請讓我問一下!知道請求鏈接是否從電子郵件帳戶

有沒有辦法知道一個URL是否被請求從一個電子郵件帳戶?

事情是:一個頁面只能通過隨機提供CAPTCHA CODE來訪問。但我希望能夠通過電子郵件帳戶訪問相同的頁面。

所以我的問題是,如果有可能知道請求的url是否來自電子郵件帳戶。

回答

2

你的意思是它是否來自電子郵件?
在這種情況下,你可以做這樣的事情

<a href="http://example.com/page?o=email">Click here to go to our website</a> 

起源也被保存在一個表中,所以它不是很明顯那是什麼。 例如,來源#1可以是電子郵件。

<a href="http://example.com/page?o=1">Click here to go to our website</a> 

然後拿到起源

<?php 
switch($_GET['o']) { 
    case 'email': 
    // Origin is email 
    break; 

    case '1': // this would probably interfere with true, hence the quotes 
    // Origin is email 
    break; 

    default: 
    // No origin; Captcha 
    break; 
} 
?> 

對於更安全的解決方案,它可以是一個授權密鑰,當電子郵件相比,一個在鏈路被送往事後產生。

<?php // The page sending the mail 
$key = md5(time()); // Or something else, maybe shorten it to fit better in the url 

    // Save the key in a table 

mail(); // Mail with unique link with ?o=$key in the end 
?> 

<?php // The page 
if(isset($_GET['o'])) { 
    // Check if the key exists in the table and delete it because it is used. 
} 
?> 
+0

謝謝!!!我用最後的選擇解決它! – 2013-04-11 19:51:12

相關問題