douxian9943 2011-01-24 18:21
浏览 68
已采纳

检查用户是否通过电子邮件激活了他们的帐户并在点击激活链接PHP / JavaScript后显示消息

I'm working with the Zend Framework on a project that requires the user to activate their account by checking their email and clicking on the activation link. The activation link works fine and the user can login once their account is set active. My question is how can i display a message when the user clicks on the activation link and get redirected to the home page, acknowledging that their account has been activated.

I was trying to write an if statement to check if HTTP_REFERER = the URL of the activation link. But that didn't work. Any help would be greatly appreciated.

Here's the if statement:

<script language="javascript" type="text/javascript">
$(document).ready(function() {

<?php if ($_SERVER['HTTP_REFERER'] == 'activationLinkGoesHere'){ ?>

    $("#suc_message").html('<?php echo 'Your account has been activated!';?>');
    $("#suc_message").fadeIn(2000);
    $("#suc_message").fadeOut(20000);

<?php } ?>

});
</script>

Thanks :)

  • 写回答

3条回答 默认 最新

  • doushi2845 2011-01-24 18:25
    关注

    Sorry for the original answer, I did not read this properly.

    I personally would just add something on the end of the url:

    http://mysite.com/thanks.php?Reg=1
    

    ..and look for the reg part and inject the message if it exists.

    edit

    Returning to this, I'll add that it is very important to keep the url addition to something that is a boolean value. For example, you could display multiple messages if you found ?Reg=1 or ?LoggedIn=1 and displayed "You registered OK" and "You logged in OK" respectively.

    Don't pass anything in that your javascript then uses for display or otherwise.

    Don't make it fire any actions.

    Follow the above and you'll be safe from people fiddling with the url to have fun with you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?