Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1. <?php
  2. include "Mail.php";
  3. mysql_connect("localhost", "servatrice", "calciareasino") or die(mysql_error());
  4. mysql_select_db("servatrice") or die(mysql_error());
  5. if ($_POST['form_submitted'] == '1') {
  6.  
  7. ## Form was submitted,the user is registering!
  8. $activationkey =  mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
  9. $sql="INSERT INTO cockatrice_users (name, password, email, activationkey, active)
  10.  
  11. VALUES
  12.  
  13.  
  14. ('$_POST[username]', '$_POST[password]', '$_POST[email]','$activationkey', '0')";
  15. if (!mysql_query($sql))
  16.  
  17.   {
  18.  
  19.   die('Error: ' . mysql_error());
  20.  
  21.   }
  22. ##Send activation Email
  23.  
  24.  require_once "Mail.php";
  25.  
  26.  $from = "MagicZN";
  27.  $to = "swiftzn@gmail.com";
  28.  $subject = "Hi!";
  29.  $body = "Hi,\n\nHow are you?";
  30.  
  31.  $host = "localhost:25";
  32.  $username = "magiczn@webafrica.org.za";
  33.  $password = "calciareasino";
  34.  
  35.  $headers = array ('From' => $from,
  36.    'To' => $to,
  37.    'Subject' => $subject);
  38.  $smtp = Mail::factory('smtp',
  39.    array ('host' => $host,
  40.      'auth' => true,
  41.      'username' => $username,
  42.      'password' => $password));
  43.  
  44.  $mail = $smtp->send($to, $headers, $body);
  45.  
  46.  if (PEAR::isError($mail)) {
  47.    echo("<p>" . $mail->getMessage() . "</p>");
  48.   } else {
  49.    echo("<p>Message successfully sent!</p>");
  50.   }
  51.  
  52. }else{
  53.  
  54.  
  55.  ##User isn't registering, check verify code and change activation code to null, status to activated on success
  56.  
  57. $queryString = $_SERVER['QUERY_STRING'];
  58.  
  59. $query = "SELECT * FROM cockatrice_users";
  60.  
  61. $result = mysql_query($query) or die(mysql_error());
  62.  
  63.   while($row = mysql_fetch_array($result)){
  64.  
  65.     if ($queryString == $row["activationkey"]){
  66.  
  67.        echo "Congratulations!" . $row["name"] . " Your MagicZN Account is now Activated.";
  68.  
  69.        $sql="UPDATE cockatrice_users SET activationkey = '', active='1' WHERE (id = $row[id])";
  70.  
  71.        if (!mysql_query($sql))
  72.  
  73.   {
  74.  
  75.         die('Error: ' . mysql_error());
  76.  
  77.   }
  78.  
  79.     }
  80.  
  81.   }
  82.  
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement