php - Sending an email verification after registering -


i want, users register on site, have activate account first, before using it. problem is, don't email email test account.

before start posting code, problem be, i'm working on local machine xampp?

otherwise, here code snippet

$random = substr(number_format(time() * rand(),0,'',''),0,10);     $insertmailverify = $this->db->prepare("insert mailverify (mailaddress, token, datetime) values (:mailaddress, :token, :date)");     $insertmailverify->execute(array(':mailaddress'=>$emailaddress,                                      ':token'=>$random,                                      ':date'=>$date));      $to = $emailaddress;     $subject = "activating account";     $body = "hi, in order activate account please visit http://localhost/finalyear/activation.php?email=".$emailaddress." , fill in verification code $random";     if(mail($to, $subject, $body))     {         echo ("<p>message success</p>");     }     else {         echo ("<p>message fail</p>");     } 

just in case wonder take $emailaddress from: code snippet, let software echo email address, , it's correct. goes in "message success" if case, still can't email. problem?

after submit form can use code or link , send user email id

$message = "your activation code ".$code.""; $to=$email; $subject="activation code talkerscode.com"; $from = 'your email'; $body='your activation code '.$code.' please click on link <a href="verification.php">verify.php?id='.$db_id.'&code='.$code.'</a>to activate  account.'; $headers = "from:".$from; mail($to,$subject,$body,$headers);  echo "an activation code sent check emails"; 

code talkerscode.com complete tutorial visit http://talkerscode.com/webtricks/account-verification-system-through-email-using-php.php


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -