Sunday, February 1, 2015

Sintak Register di PHP

FORM Register

<!DOCTYPE html>
<html class="bg-black">
    <head>
        <meta charset="UTF-8">
        <title>AdminLTE | Registration Page</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- font Awesome -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />
    <style>
     

        #availability_status {
    font-size:11px;
    margin-left:10px;
}
    #password_status {
    font-size:11px;
    margin-left:10px;
}
#msg {
    font-size:11px;
    margin-left:10px;
}
}

    </style>

    </head>
    <body class="bg-black">

        <div class="form-box" id="login-box">
            <div class="header">Register </div>
            <form action="register_check.php" method="post">
                <div class="body bg-gray">
                    <div class="form-group">
                        <input type="text" name="NIP" class="form-control" placeholder="NIP" id='sk' required/>
                        <span id='availability_status'></span>
                    </div>
                    <div class="form-group">
                        <input type="text" name="name" class="form-control" placeholder="Full name" required/>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" class="form-control" placeholder="Password" id='password' required/>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password2" class="form-control" placeholder="Retype password" id='password2' required/>
                        <span id='password_status'></span>
                    </div>
                    <div class="form-group">
                        <input  name="email" class="form-control" placeholder="email" oninvalid="InvalidMsg(this);"  oninput="InvalidMsg(this);"  type="email" required="required"/>
                    </div>
                </div>
                <div class="footer">                  

                    <button type="submit" class="btn bg-olive btn-block">Sign me up</button>

                    <a href="../login/login.php" class="text-center">Login</a>
                </div>
            </form>

         
        </div>

<script src="../scripts/formvalidasi.js" type="text/javascript"></script>

        <!-- jQuery 2.0.2 -->
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="../js/bootstrap.min.js" type="text/javascript"></script>

    </body>
</html>

<script type="text/javascript">
$(document).ready(function()//When the dom is ready
{
$("#password2").change(function()
{ //if theres a change in the password2 textbox
var password = $("#password").val();
var password2 = $("#password2").val();//Get the value in the password2 textbox

if(password2.length > 4)//if the lenght greater than 3 characters

{
$("#password_status").html('<img src="../img/ajax-loader1.gif" align="absmiddle">&nbsp;Checking availability...');
//Add a loading image in the span id="password_status"
    if(password2 == password)
    {
 
    $("#password_status").html('<img src="../img/available.png" align="absmiddle">   ');
 
    //add this image to the span with id "password_status"
    }
    else  //if it returns "1"
    {
     $("#password_status").html('<img src="../img/not_available.png" align="absmiddle">');
    }
 


}
else
{

$("#password_status").html('<font color="#cc0000"> password terlalu pendek</font>');
//if in case the password2 is less than or equal 3 characters only
}



return false;
});

});
function InvalidMsg(textbox) {
 
    if (textbox.value == '') {
        textbox.setCustomValidity('Required email address');
    }
    else if(textbox.validity.typeMismatch){
        textbox.setCustomValidity('please enter a valid email address');
    }
    else {
        textbox.setCustomValidity('');
    }
    return true;
}
</script>

SINTAK ReGISTeR CHeCK

include "../koneksi/koneksi.php";
$NIP=$_POST['NIP'];
$nama=$_POST['name'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$pengacak  = 'NDJS3289JSKS190JISJI';
$newPasswordEnkrip = md5($pengacak . md5($password) . $pengacak);

$email=$_POST['email'];
$status=0;
$blok=1;
$to = $_POST['email'];
$judul = "Aktivasi Akun Anda";
$dari = "From: daniheriyanto@gmail.com \n";
$dari .= "Content-type: text/html \r\n";

$pesan = "Klik link berikut untuk mengaktifkan akun: <br />";
$pesan .= "<a href='http://ptkdikporabna.org/sip/register/konfirm.php?email=".$_POST['email']."&kode=$NIP&username=".$_POST['name']."'>klik di sini</a>";

$kirim = mail($to, $judul, $pesan, $dari);

$sql=mysql_query("insert into t_pengawas (id_pengawas,nama,password,email,status,blok) values('$NIP','$nama','$newPasswordEnkrip','$email',$status,$blok)");
if ($sql && $kirim){
header("location:../login/login.php?init=4");
}
else
{
echo" <p class='btn btn-large btn-block' align=center>GAGAL<a href='register.html'>ulangi</a></p>";
}


?>

No comments:

Post a Comment