Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>NETTUTS > Sign up</title>
- <link href="css/style.css" type="text/css" rel="stylesheet" />
- </head>
- <body>
- <!-- start header div -->
- <div id="header">
- <h3>NETTUTS > Sign up</h3>
- </div>
- <!-- end header div -->
- <!-- start wrap div -->
- <div id="wrap">
- <!-- start php code -->
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- //Load Composer's autoloader
- require 'vendor/autoload.php';
- define("DB_USER", "root");
- define("DB_PASSWORD", "");
- define("DB_DATABASE", "akademik");
- define("DB_HOST", "localhost");
- $cn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
- if(isset($_POST['name']) && !empty($_POST['name']) AND isset($_POST['email']) && !empty($_POST['email'])){
- $name = $_POST['name']; // Turn our post into a local variable
- $email = $_POST['email']; // Turn our post into a local variable
- // Return Success - Valid Email
- $msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been send to your email.';
- $hash = md5( rand(0,1000) );
- $password = rand(1000,5000);
- mysqli_query($cn,"INSERT INTO users (username, password, email, hash) VALUES('$name',md5('".$password."'),'$email','$hash')");
- $to = $email; // Send email to our user
- $subject = 'Signup | Verification'; // Give the email a subject
- $message = '
- Thanks for signing up!
- Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
- ------------------------
- Username: '.$name.'
- Password: '.$password.'
- ------------------------
- Please click this link to activate your account:
- http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'
- '; // Our message above including the link
- $headers = 'From:noreply@yourwebsite.com' . "\r\n"; // Set from headers
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'setiadikindi@gmail.com'; // SMTP username
- $mail->Password = 'kinkin12';
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- //Recipients
- $mail->setFrom('kinsetiadi@gmail.com', 'Mailer');
- $mail->addAddress($email); // Name is optional
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $subject;
- $mail->Body = '
- Thanks for signing up! <br/>
- Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below. <br/>
- ------------------------ <br/>
- Username: '.$name.' <br/>
- Password: '.$password.' <br/>
- ------------------------ <br/>
- Please click this link to activate your account: <br/>
- http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'
- ';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }
- ?>
- <!-- stop php code -->
- <!-- title and description -->
- <h3>Signup Form</h3>
- <p>Please enter your name and email addres to create your account</p>
- <!-- start sign up form -->
- <form action="" method="post">
- <label for="name">Name:</label>
- <input type="text" name="name" value="" />
- <label for="email">Email:</label>
- <input type="text" name="email" value="" />
- <input type="submit" class="submit_button" value="Sign up" />
- </form>
- <!-- end sign up form -->
- </div>
- <!-- end wrap div -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement