validation link via email

前端 未结 7 991
盖世英雄少女心
盖世英雄少女心 2020-12-15 01:24

When a user subscribes to my newsletter via their email address, using php, how would I send them an \'Activation Link\' via email to confirm it is their email address and n

7条回答
  •  [愿得一人]
    2020-12-15 01:51

    no database needed. you can send all data in the hyperlink signed by hash

    I've answered similar question recently even with expiration time.
    though it was for the password recovery link, but idea is the same

    $token = sha1($time.$email.$salt).dechex(time()).dechex($user_id);
    $link = "http://".$domain."/restorepass/?token=$token";
    

    whole token would looks like single hexdecimal number and it would be hard to guess it's meaning.

    upon receive just split and decode it back.
    Neat, IMO.

提交回复
热议问题