Guest User

Untitled

a guest
Jan 10th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2.  
  3. $host="localhost"; // Host name
  4. $username=""; // Mysql username
  5. $password=""; // Mysql password
  6. $db_name=""; // Database name
  7.  
  8.  
  9. //Connect to server and select database.
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. ?>
  14.  
  15. <?php
  16.  
  17. include('config.php');
  18.  
  19. // table name
  20. $tbl_name=temp_members_db;
  21.  
  22. // Random confirmation code
  23. $confirm_code=md5(uniqid(rand()));
  24.  
  25. // values sent from form
  26. $name=$_POST['name'];
  27. $email=$_POST['email'];
  28. $country=$_POST['country'];
  29.  
  30. // Insert data into database
  31. $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')";
  32. $result=mysql_query($sql);
  33.  
  34. // if suceesfully inserted data into database, send confirmation link to email
  35. if($result){
  36.  
  37. // ---------------- SEND MAIL FORM ----------------
  38.  
  39.  
  40. // send e-mail to ...
  41. $to=$email;
  42.  
  43. // Your subject
  44. $subject="Your confirmation link here";
  45.  
  46. // From
  47. $header="from: your name <your email>";
  48.  
  49. // Your message
  50. $message="Your Comfirmation link \r\n";
  51. $message.="Click on this link to activate your account \r\n";
  52. $message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code";
  53.  
  54.  
  55. // send email
  56. $sentmail = mail($to,$subject,$message,$header);
  57.  
  58. }
  59.  
  60.  
  61. // if not found
  62. else {
  63. echo "Not found your email in our database";
  64. }
  65.  
  66.  
  67. // if your email succesfully sent
  68. if($sentmail){
  69. echo "Your Confirmation link Has Been Sent To Your Email Address.";
  70. }
  71. else {
  72. echo "Cannot send Confirmation link to your e-mail address";
  73. }
  74.  
  75. ?>
Add Comment
Please, Sign In to add comment