Advertisement
Guest User

proses_daftar

a guest
Nov 22nd, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.92 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. function rand_string( $length ) {
  4.     $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
  5.     $size = strlen( $chars );
  6.     for( $i = 0; $i < $length; $i++ ) {
  7.         $str .= $chars[ rand( 0, $size - 1 ) ];
  8.     }
  9.     return $str;
  10. }
  11. include 'lib/koneksi.php';
  12. $email = $_POST['txtemail'];
  13. $password1 = $_POST['txtpassword1'];
  14. $password2 = $_POST['txtpassword2'];
  15. $namalengkap = $_POST['txtnama'];
  16. $alamat = $_POST['txtalamat'];
  17. $id = rand_string( 10 );
  18. if (!isset($email)) {
  19. echo "Lengkapi email";
  20. }
  21. else if (!isset($password1)) {
  22.     echo "Lengkapi password";
  23. }
  24. else if (!isset($namalengkap)) {
  25.     echo "Lengkapi nama anda";
  26. }
  27. else if ($password1!=$password2) {
  28.     echo "Password tidak sama";
  29. }
  30. else if (!isset($alamat)) {
  31.     echo "Lengkapi alamat";
  32. }
  33. else {
  34.     // cek apakah email sudah terdaftar
  35.     $sqlcheck = "SELECT email FROM tb_member WHERE email='$email'";
  36.     $temu = mysql_query($query);
  37.     if ($temu && mysql_num_rows($temu) > 0) {
  38.         echo "user telah terdaftar";
  39.     }
  40.     else {
  41.         $sqldaftar="INSERT INTO tb_member (email,password,nama_lengkap,alamat) VALUES('".$_POST['txtemail']."','".$_POST['txtpassword1']."','".$_POST['txtnama']."','".$_POST['txtalamat']."')";
  42.         //echo $sqldaftar;
  43.         //exit;
  44.         mysql_query($sqldaftar);
  45.         if ($sqldaftar) {
  46. echo "Daftar Suskses Silahkan Aktivasi";
  47.         } else {
  48. echo "gagal cek lagi";
  49.         }
  50.         require_once('lib/mailer/class.phpmailer.php'); //menginclude librari phpmailer
  51.         $mail             = new PHPMailer();
  52.         $body             =
  53.         "<body style='margin: 10px;'>
  54.         <div style='width: 640px; font-family: Helvetica, sans-serif; font-size: 13px; padding:10px; line-height:150%; border:#eaeaea solid 10px;'>
  55.         <br>
  56.         <strong>Terima Kasih Telah Mendaftar di situs Belanja Online Nomer Satu Di Indonesia UD.Toko Patra</strong><br>
  57.         <b>Email Anda : </b>".$email."<br>
  58.         <b>Password Anda  : </b>".$password."<br>
  59.         <b>Nama Lengkap Anda : </b>".$namalengkap."<br>
  60.         <b>Alamat : </b>".$alamat."<br>
  61.         <b>LINK Konfirmasi : </b>http://localhost/si_comerce/modul/daftar/confirm.php?id=".$id."<br>
  62.         <br>
  63.         </div>
  64.         </body>";
  65.         $body             = eregi_replace("[\]",'',$body);
  66.         $mail->IsSMTP();    // menggunakan SMTP
  67.         $mail->SMTPDebug  = 1;   // mengaktifkan debug SMTP
  68.         $mail->SMTPAuth   = true;   // mengaktifkan Autentifikasi SMTP
  69.         $mail->Host     = 'mail.telkomsel.com'; // host sesuaikan dengan hosting mail anda
  70.         $mail->SMTPSecure = "ssl";
  71.         $mail->Port = 465;
  72.         $mail->Username   = "susilobambangyudhoyno@gmail.com"; // username email akun
  73.         $mail->Password   = "singleman";        // password akun
  74.         $mail->SetFrom('susilobambangyudhoyno@gmail.com', 'Halo Naanng');
  75.  
  76.         $mail->Subject    = "Aktivasi";
  77.         $mail->MsgHTML($body);
  78.  
  79.         $address = $email; //email tujuan
  80.         $mail->AddAddress($address, "Hallo (Reciever name)");
  81.  
  82.         if(!$mail->Send()) {
  83.             echo "Ada masalah !!!!: " . $mail->ErrorInfo;
  84.         } else {
  85.             echo "Mail Sukses";
  86.         }
  87.     }
  88.  
  89. }
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement