开发者

check if user activated their account via email and display message after clicking on activation link 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 :)


Is there a reason you couldn't set a session variable on the activation page and then check for it in php on the home page? If it's set, use php to inject some javascript (just a simple boolean flag should do) that you then check when the page loads.


If you use Zend Framework, then you must use FlashMessenger. It's designed for that exact purpose.

Remember to use the helper's static method in your controller's action.

Then for the view use noumenal's excellent view helper; you can then put it in your layout or view script.

It's that easy. Hope it helps.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜