Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "Mail.php";
- mysql_connect("localhost", "servatrice", "calciareasino") or die(mysql_error());
- mysql_select_db("servatrice") or die(mysql_error());
- if ($_POST['form_submitted'] == '1') {
- ## Form was submitted,the user is registering!
- $activationkey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
- $sql="INSERT INTO cockatrice_users (name, password, email, activationkey, active)
- VALUES
- ('$_POST[username]', '$_POST[password]', '$_POST[email]','$activationkey', '0')";
- if (!mysql_query($sql))
- {
- die('Error: ' . mysql_error());
- }
- ##Send activation Email
- require_once "Mail.php";
- $from = "MagicZN";
- $to = "swiftzn@gmail.com";
- $subject = "Hi!";
- $body = "Hi,\n\nHow are you?";
- $host = "localhost:25";
- $username = "magiczn@webafrica.org.za";
- $password = "calciareasino";
- $headers = array ('From' => $from,
- 'To' => $to,
- 'Subject' => $subject);
- $smtp = Mail::factory('smtp',
- array ('host' => $host,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password));
- $mail = $smtp->send($to, $headers, $body);
- if (PEAR::isError($mail)) {
- echo("<p>" . $mail->getMessage() . "</p>");
- } else {
- echo("<p>Message successfully sent!</p>");
- }
- }else{
- ##User isn't registering, check verify code and change activation code to null, status to activated on success
- $queryString = $_SERVER['QUERY_STRING'];
- $query = "SELECT * FROM cockatrice_users";
- $result = mysql_query($query) or die(mysql_error());
- while($row = mysql_fetch_array($result)){
- if ($queryString == $row["activationkey"]){
- echo "Congratulations!" . $row["name"] . " Your MagicZN Account is now Activated.";
- $sql="UPDATE cockatrice_users SET activationkey = '', active='1' WHERE (id = $row[id])";
- if (!mysql_query($sql))
- {
- die('Error: ' . mysql_error());
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement