php - Generate a unique link for each email id :Yii -


i have yii web app user can send mass email. in mail send unique link each email id. don't have idea how this.

where should start in order implement this?

1). how generate unique links automatically each email id.

2). how track response if user clicks on link?

sounds you'd need store data somehow after each email sent, unique hash. inside email use unique hash in url query.

then on page you'd use hash call info stored email, lets discussion panel or something.

a simple effective token can generated so:

$token = substr( md5( microtime() ), -12 ); 

you can generate unique backwards compatible hash users email. (this insecure!)

$token = base64_encode ( $email ); // users email encoded 

you can use code decode , search email in database

$emailtoken = base64_decode( $_get['t'] ); // contains users email 

you can test see if valid token make secure against basic injections so:

if ( base64_encode( base64_decode( $_get['t'] ) ) === $_get['t'] ) {     // valid base64... hope valid email?     $emailtoken = filter_var( base64_decode( $_get['t'] ), filter_sanitize_email );     if ( filter_var( $emailtoken, filter_validate_email ) ) {         // email valid. call email info     } } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -