Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--filename: views/myform.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset='utf-8'/>
- <title>Simple Validation</title>
- </head>
- <body>
- <?php echo validation_errors(); ?>
- <?php echo form_open('form'); ?>
- <label>tagihan anda<label>
- <input type='text' name='tagihan' id='tagihan' value='<?php echo set_value('tagihan'); ?>'/><br />
- <label>bayar tagihana<label>
- <input type='text' name='bayar' id='bayar' value='<?php echo set_value('bayar'); ?>'/><br />
- <input type='submit' value='submit'/>
- </form>
- </body>
- </html>
- //--filename: views/formsuccess.php
- <html>
- <head>
- <title>My Form</title>
- </head>
- <body>
- <h3>Your form was successfully submitted!</h3>
- <p><?php echo anchor('form', 'Try it again!'); ?></p>
- </body>
- </html>
- //--filename: controller/form.php
- <?php
- class Form extends CI_Controller {
- function index()
- {
- $this->load->helper(array('form', 'url'));
- $this->load->library('form_validation');
- $this->form_validation->set_rules('bayar', 'Bayar', 'required|less_than['. $this->input->post('tagihan').']');
- if ($this->form_validation->run() == FALSE)
- {
- $this->load->view('myform');
- }
- else
- {
- $this->load->view('formsuccess');
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement