Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- function rand_string( $length ) {
- $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- $size = strlen( $chars );
- for( $i = 0; $i < $length; $i++ ) {
- $str .= $chars[ rand( 0, $size - 1 ) ];
- }
- return $str;
- }
- include 'lib/koneksi.php';
- $email = $_POST['txtemail'];
- $password1 = $_POST['txtpassword1'];
- $password2 = $_POST['txtpassword2'];
- $namalengkap = $_POST['txtnama'];
- $alamat = $_POST['txtalamat'];
- $id = rand_string( 10 );
- if (!isset($email)) {
- echo "Lengkapi email";
- }
- else if (!isset($password1)) {
- echo "Lengkapi password";
- }
- else if (!isset($namalengkap)) {
- echo "Lengkapi nama anda";
- }
- else if ($password1!=$password2) {
- echo "Password tidak sama";
- }
- else if (!isset($alamat)) {
- echo "Lengkapi alamat";
- }
- else {
- // cek apakah email sudah terdaftar
- $sqlcheck = "SELECT email FROM tb_member WHERE email='$email'";
- $temu = mysql_query($query);
- if ($temu && mysql_num_rows($temu) > 0) {
- echo "user telah terdaftar";
- }
- else {
- $sqldaftar="INSERT INTO tb_member (email,password,nama_lengkap,alamat) VALUES('".$_POST['txtemail']."','".$_POST['txtpassword1']."','".$_POST['txtnama']."','".$_POST['txtalamat']."')";
- //echo $sqldaftar;
- //exit;
- mysql_query($sqldaftar);
- if ($sqldaftar) {
- echo "Daftar Suskses Silahkan Aktivasi";
- } else {
- echo "gagal cek lagi";
- }
- require_once('lib/mailer/class.phpmailer.php'); //menginclude librari phpmailer
- $mail = new PHPMailer();
- $body =
- "<body style='margin: 10px;'>
- <div style='width: 640px; font-family: Helvetica, sans-serif; font-size: 13px; padding:10px; line-height:150%; border:#eaeaea solid 10px;'>
- <br>
- <strong>Terima Kasih Telah Mendaftar di situs Belanja Online Nomer Satu Di Indonesia UD.Toko Patra</strong><br>
- <b>Email Anda : </b>".$email."<br>
- <b>Password Anda : </b>".$password."<br>
- <b>Nama Lengkap Anda : </b>".$namalengkap."<br>
- <b>Alamat : </b>".$alamat."<br>
- <b>LINK Konfirmasi : </b>http://localhost/si_comerce/modul/daftar/confirm.php?id=".$id."<br>
- <br>
- </div>
- </body>";
- $body = eregi_replace("[\]",'',$body);
- $mail->IsSMTP(); // menggunakan SMTP
- $mail->SMTPDebug = 1; // mengaktifkan debug SMTP
- $mail->SMTPAuth = true; // mengaktifkan Autentifikasi SMTP
- $mail->Host = 'mail.telkomsel.com'; // host sesuaikan dengan hosting mail anda
- $mail->SMTPSecure = "ssl";
- $mail->Port = 465;
- $mail->Username = "susilobambangyudhoyno@gmail.com"; // username email akun
- $mail->Password = "singleman"; // password akun
- $mail->SetFrom('susilobambangyudhoyno@gmail.com', 'Halo Naanng');
- $mail->Subject = "Aktivasi";
- $mail->MsgHTML($body);
- $address = $email; //email tujuan
- $mail->AddAddress($address, "Hallo (Reciever name)");
- if(!$mail->Send()) {
- echo "Ada masalah !!!!: " . $mail->ErrorInfo;
- } else {
- echo "Mail Sukses";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement