这可能是不可能的,但是,请让我问它!
有没有办法知道是否通过电子邮件帐户请求了网址?
事情是:有一个页面只能通过提供随机CAPTCHA代码来访问。但我想通过电子邮件帐户访问同一页面。
所以我的问题是,如果可以知道所请求的网址是否来自电子邮件帐户。
答案 0 :(得分: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.
}
?>