Registrasi Email degang PHP dan MySql

db_regristrasi.sql

-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 05, 2014 at 11:44 AM
-- Server version: 5.1.41
-- PHP Version: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `lukman_hakim`
--

-- --------------------------------------------------------

--
-- Table structure for table `tb_admin`
--

CREATE TABLE IF NOT EXISTS `tb_admin` (
  `admin_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `admin_username` varchar(20) NOT NULL,
  `admin_password` varchar(50) NOT NULL,
  `admin_email` varchar(30) NOT NULL,
  PRIMARY KEY (`admin_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `tb_admin`
--

INSERT INTO `tb_admin` (`admin_id`, `admin_username`, `admin_password`, `admin_email`) VALUES
(6, '11', '11', '11'),
(5, 'guntur', '736473', 'guntur_roxx@yahoo.com');

-- --------------------------------------------------------

--
-- Table structure for table `tb_category`
--

CREATE TABLE IF NOT EXISTS `tb_category` (
  `category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `category_name` varchar(12) DEFAULT NULL,
  PRIMARY KEY (`category_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;

--
-- Dumping data for table `tb_category`
--

INSERT INTO `tb_category` (`category_id`, `category_name`) VALUES
(33, '<B>NHSDS</B>'),
(12, 'Nokia'),
(11, 'Samsung'),
(10, 'Blackberry'),
(32, '<B>NHSDS</B>'),
(31, '<B>NHSDS</B>');

-- --------------------------------------------------------

--
-- Table structure for table `tb_mhs`
--

CREATE TABLE IF NOT EXISTS `tb_mhs` (
  `mhs_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mhs_name` varchar(10) DEFAULT NULL,
  `mhs_address` varchar(12) DEFAULT NULL,
  PRIMARY KEY (`mhs_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;

--
-- Dumping data for table `tb_mhs`
--

INSERT INTO `tb_mhs` (`mhs_id`, `mhs_name`, `mhs_address`) VALUES
(1, 'Anisa', 'Bandung'),
(2, 'Fatimah', 'Jakarta'),
(3, 'Andriano', 'Bali'),
(4, 'Jaka', 'Irian'),
(5, 'Basuki', 'Kalimantan'),
(6, 'Abi', 'Sumantra'),
(7, 'Nurul', 'Jogja'),
(8, 'sani', 'jogja'),
(9, 'dfdf', 'dfdf'),
(10, 'fdf', 'dfdf'),
(11, 'dfdf', 'df'),
(12, 'dfdf', 'dfdf'),
(13, 'ffdf', 'dfd'),
(14, 'dfd', 'dfd'),
(15, 'dfdfdf', 'fdf'),
(16, 'dfd', 'dfdf'),
(17, 'dfdf', 'dfdf'),
(18, 'dfdfdf', 'dfd'),
(19, 'dfdf', 'dfdf'),
(20, 'dfdf', 'dfdf'),
(21, 'dfdf', 'dfdf');

-- --------------------------------------------------------

--
-- Table structure for table `tb_product`
--

CREATE TABLE IF NOT EXISTS `tb_product` (
  `product_id` int(2) unsigned zerofill NOT NULL AUTO_INCREMENT,
  `category_id` int(11) DEFAULT NULL,
  `product_name` varchar(12) DEFAULT NULL,
  `product_price` int(11) DEFAULT NULL,
  PRIMARY KEY (`product_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

--
-- Dumping data for table `tb_product`
--

INSERT INTO `tb_product` (`product_id`, `category_id`, `product_name`, `product_price`) VALUES
(01, 11, 'Galaxsi S II', 2000000),
(02, 10, 'Gemini 8250', 900000),
(03, 10, 'Dakota 9000', 8000000),
(04, 11, 'Duos', 200000),
(05, 10, 'Dakota 2014', 100000),
(06, 12, 'Nokia 88888', 900000),
(07, 12, 'Nokia N70', 800000),
(08, 12, 'Nokia 1200', 800000),
(09, 12, 'Nokia Cino', 70000),
(14, 0, '', 0);

-- --------------------------------------------------------

--
-- Table structure for table `tb_temp`
--

CREATE TABLE IF NOT EXISTS `tb_temp` (
  `temp_verifikasi` varchar(50) DEFAULT NULL,
  `temp_username` varchar(20) DEFAULT NULL,
  `temp_password` varchar(32) DEFAULT NULL,
  `temp_email` varchar(50) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tb_temp`
--

INSERT INTO `tb_temp` (`temp_verifikasi`, `temp_username`, `temp_password`, `temp_email`) VALUES
('11', '2wedwqe', 'sdsds', 'sdsd'),
('3d5f9c496b0bec4fcc2d06b76e97d829', 'guntur', '736473', 'guntur_roxx@yahoo.com');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 

daftar.php

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <meta name="author" content="lolkittens" />

    <title>Untitled 2</title>
</head>

<body>
<?php
error_reporting(0);
if($_GET['action']=='gagal'){
     echo"password tidak terkirim ke email anda";
}
?>

<form method="post" action="check.php">
<table>
<tr><td>User</td><td>:</td><td><input type="text" name="frm_username"/></td></tr>
<tr><td>Password</td><td>:</td><td><input type="password" name="frm_password"/></td></tr>
<tr><td>Email</td><td>:</td><td><input type="text" name="frm_email"/></td></tr>

<tr><td><input type="submit" value="Daftar"/></td></tr>
</table>
</form>


</body>
</html


check.php

<?php
require_once('inc-db.php');
$kode_acak=md5(uniqid(rand()));
$var_username=$_POST['frm_username'];
$var_password=$_POST['frm_password'];
$var_email=$_POST['frm_email'];
/*
echo "Kode :".$kode."<br>";
echo "Username :".$var_username."<br>";
echo "Password :".$var_password."<br>";
echo "Email :".$var_email."<br>";
exit; */


$sql_insert="INSERT INTO tb_temp VALUES ('$kode_acak','$var_username','$var_password','$var_email')";
$result=mysql_query($sql_insert);
if ($result){
  /*  $sql_check="SELECT temp_verifikasi FROM tb_temp";
    $result=mysql_query($sql_check);
    $data=mysql_fetch_array($result);
    $kode=$data['temp_verifikasi'];
    //------------------------------------  */

    $tujuan=$var_email;
    $subject="Tes Email";
    $pesan="
    Klik
    http://edi091.hol.es/lukman_hakim/regristrasi/confirm.php?kode=$kode_acak
    untuk konfirmasi
    ";
    $dari="from : joker@edi091.hol.es";
    mail($tujuan,$subject,$pesan,$dari);
   // echo $kode;
    echo "<br>berhasil daftar silahkan cek email anda untuk konfirmasi";
   // echo "<a href='confirm.php?kode=".$kode."'>http://localhost/acak/lukman_hakim/regristrasi/confirm.php?kode=$kode</a>";  
}

?>

confirm.php

<?php
require_once('inc-db.php');
$var_kode=$_GET['kode'];
//echo $var_kode;
//exit;
$sql_check="SELECT * FROM tb_temp WHERE temp_verifikasi='".$var_kode."'";
$result=mysql_query($sql_check);
$rows=mysql_num_rows($result);
//Apa bila kode verifikasi ditemukan
//echo $rows;
//exit;

if($rows > 0 ){
$data=mysql_fetch_array($result);
$var_username=$data['temp_username'];
$var_password=$data['temp_password'];
$var_email=$data['temp_email'];
//Masukan data user ke table tb_admin yang sah
$sql_insert="INSERT INTO tb_admin VALUES ('','$var_username','$var_password','$var_email')";
//echo $sql_insert;
$result12=mysql_query($sql_insert);
if($result12){
echo "Account Anda Telah diaktifkan";
//hapus  data pendaftaran sementara tersebut di table tb_temp
$sql_delete="DELETE FROM tb_temp WHERE temp_verifikasi='".$var_kode."'";
$result1=mysql_query($sql_delete);
}
}else {
    echo "kode tidak ditemukan";
}


?>



0 Response to "Registrasi Email degang PHP dan MySql"

Posting Komentar