duan2428 2013-04-09 21:17
浏览 32

知道请求链接是否从电子邮件帐户访问[关闭]

that may not be possible, but, please let me ask it!

is there a way to know if an url is been requested form an email account?

the thing is : a got a page who can only be accessed by giving a random CAPTCHA CODE. but i wan to make the same page be accesible from an email account.

so my question is , if it's possible to know if the requested url is coming from an email account.

  • 写回答

1条回答 默认 最新

  • du4822 2013-04-09 21:27
    关注

    Do you mean if it's coming from an e-mail?
    In that case, you could do something like this

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

    The origins could also be saved in a table, so it wasn't obvious what it was. For example origin #1 could be email.

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

    And then get the origin

    <?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;
    }
    ?>
    

    For a more secure solution, it could be an authorization key, generated when the email was sent and afterwards compared to the one in the link.

    <?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.
    }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?