angka captcha tidak muncul, di code igniter

Selamat siang, minta bantuan nya suhu, saya buat login captcha di CI cuman angka captcha nya tidak muncul kira2 apanya yah, saya sudah pusing cari problime nya hehe

Captcha.php (controller)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Captcha extends CI_Controller
{
    function __construct() {
		parent::__construct();
		// Load the captcha helper
		$this->load->helper('captcha');
    }

    public function index(){
		// If captcha form is submitted
		if($this->input->post('submit')){
			$inputCaptcha = $this->input->post('captcha');
			$sessCaptcha = $this->session->userdata('captchaCode');
			if($inputCaptcha === $sessCaptcha){
				echo 'Captcha code matched.';
			}else{
				echo 'Captcha code was not match, please try again.';
			}
		}

		// Captcha configuration
		$config = array(
			'img_path'      => 'captcha_images/',
			'img_url'       => base_url().'captcha_images/',
			'img_width'     => '150',
			'img_height'    => 50,
			'word_length'   => 8,
			'font_size'     => 16
		);
		$captcha = create_captcha($config);

		// Unset previous captcha and store new captcha word
		$this->session->unset_userdata('captchaCode');
		$this->session->set_userdata('captchaCode',$captcha['word']);

		// Send captcha image to view
		$data['captchaImg'] = $captcha['image'];
		print_r(create_captcha());exit;

		// Load the view
		$this->load->view('captcha/index', $data);
    }

	public function refresh(){
		// Captcha configuration
		$config = array(
			'img_path'      => 'captcha_images/',
			'img_url'       => base_url().'captcha_images/',
			'img_width'     => '150',
			'img_height'    => 50,
			'word_length'   => 8,
			'font_size'     => 16
		);
		$captcha = create_captcha($config);

		// Unset previous captcha and store new captcha word
		$this->session->unset_userdata('captchaCode');
		$this->session->set_userdata('captchaCode',$captcha['word']);

		// Display captcha image
		echo $captcha['image'];
	}
}

Login.php (Controller)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->helper(array('form','url'));
		$this->load->model('Login_model');
	}
	function index()
	{
		 $this->load->view('login');
	}

	function ceklogin(){
		$username = $this->input->post('username');
		$password = $this->input->post('password');

		$query = $this->Login_model->validate_login($username,$password);

		if($query){
			redirect('Pages');
		}
		else{
		echo "<script>alert('Gagal Login');
			  window.location='". base_url()."Login'</script>";
		}
	}

	function captcha(){
		$gbr         = imagecreate(200, 50);
		imagecolorallocate($gbr, 69, 179, 157);
		$color       = imagecolorallocate($gbr, 253, 252, 252);
		$font        = base_url().'/assets/captcha/font/Allura-Regular.otf';
		$ukuran_font = 20;
		$posisi      = 32;
		// membuat nomor acak dan ditampilkan pada gambar
		for($i=0;$i<=5;$i++) {
			// jumlah karakter
			$angka       = rand(0, 9);
			$_SESSION['Captcha'] .=$angka;
			$kemiringan  = rand(20, 20);

			// imagettftext($gbr, $ukuran_font, $kemiringan, 8+15*$i, $posisi, $color, $font, $angka);
		}

		//untuk membuat gambar
		imagepng($gbr);
		imagedestroy($gbr);
		$gbr;
	}
}

login.php(View)

 <div class="wrap-input100 validate-input m-b-26" data-validate="Username is required">
            <span class="label-input100">Username</span>
            <input class="input100" type="text" name="username" placeholder="enter username">
            <span class="focus-input100"></span>
          </div>
          <div class="wrap-input100 validate-input m-b-18" data-validate = "Password is required">
            <span class="label-input100">Password</span>
            <input class="input100" type="password" name="password" placeholder="enter password">
            <span class="focus-input100"></span>
          </div>
          <div class="wrap-input100 validate-input m-b-18" data-validate = "cannot be empty">
            <img src="<?=base_url();?>Login/captcha" alt="gambar" />
            <input class="input100 " type="text" name="nilaiCaptcha" placeholder="verification">
          </div>
          <div class="container-login100-form-btn">
            <button class="login100-form-btn" name="submit_login">Login</button>
          </div>
avatar Obbytokun
@Obbytokun

186 Kontribusi 16 Poin

Dipost 4 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban