Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'config/init.php';
- if($pegawai->isLoggedIn()){
- Redirect::to('profil');
- }
- //validasi
- if(Input::get('submit')) {
- //call validation object
- $validasi = new Validasi();
- //metode check
- $validasi = $validasi->check(array(
- 'username' => array(
- 'required'=> true,
- 'min'=> 4,
- 'max'=> 10,
- ),
- 'password' => array(
- 'required'=> true,
- 'min'=> 4,
- ),
- 'txtNama' => array(
- 'required' => true,
- 'min'=> 4,
- 'max'=> 30,
- ),
- 'password_verify' => array(
- 'required' => true,
- 'match' => 'password'
- )
- ));
- if($pegawai->cekUserName(Input::get('username'))){
- $errors[] = "Nama Sudah terdaftar";
- }else {
- //lolos validasi
- if($validasi->passed()){
- $pegawai->register_pegawai(array(
- //key => value
- 'kode' => Input::get('username'),
- 'password' => password_hash(Input::get('password'), PASSWORD_DEFAULT),
- 'nama' => Input::get('txtNama')
- ));
- Session::flash('Profil', 'selamat pendaftaran berhasil');
- Session::set('username', Input::get('username'));
- Redirect::to('profil');
- }else{
- //print_r($validasi->errors());
- $errors = $validasi->errors();
- }
- }
- }
- require_once 'templates/header.html';
- ?>
- <h2>Daftar sekarang</h2>
- <?php if(!empty($errors)){ ?>
- <div id="errors">
- <?php foreach ($errors as $error) { ?>
- <li> <?php echo $error; ?> </li>
- <?php } ?>
- </div>
- <?php } ?>
- <form action="register.php" method = "post">
- <pre>
- <label>Username :</label> <input type="text" name="username"> <br>
- <label>Password :</label> <input type="password" name="password"> <br>
- <label>Retype Password :</label> <input type="password" name="password_verify"> <br>
- <label>Nama :</label> <input type="text" name="txtNama"> <br>
- <input type="submit" name="submit" value=" Register ">
- </pre>
- </form>
- <?php
- require_once 'templates/footer.html';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment