Jump to content

Form not working


I-AM-OBODO

Recommended Posts

Hi,

i don't really know why my form isn't working, even when i click on empty, its still not validating.

Here's my code:

 

Controller

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

class Services extends CI_Controller {

public function __construct()
{
	parent::__construct();
	$this->load->model('services_model');
}


public function view($page = 'easylife')
{

	if ( ! file_exists('application/views/services/'.$page.'.php'))
{
	// Whoops, we don't have a page for that!
	show_404();
}

$data['title'] = ucfirst($page); // Capitalize the first letter

$this->load->view('templates/header', $data);
$this->load->view('services/'.$page, $data);
$this->load->view('templates/footer', $data);

}
public function advisory()

{
$this->load->helper('form');
$this->load->library('form_validation');

//$data['title'] = 'Create a news item';

$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('sname', 'Surname', 'required');
$this->form_validation->set_rules('fname', 'First Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('state', 'State', 'required');
$this->form_validation->set_rules('tel', 'telephone', 'required');
$this->form_validation->set_rules('msg', 'Message', 'required');

if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $data);
$this->load->view('services/'.$page, $data);
$this->load->view('templates/footer', $data);

}
else
{
	$this->news_model->set_news();
	$this->load->view('services/success');
}
}	
}

 

Model

 

<?php

class Services_model extends CI_Model {

public function __construct()
{
	$this->load->database();
}
    function insert_entry()
    {
        $data = array(
               'title' => $title,
               'sname' => $name,
		   'fname' => $name,
		   'email' => $name,
		   'state' => $name,
		   'tel' => $name,
		   'msg' => $name,
               'date' => $date
            );

	$this->db->insert('advisory', $data); 


}	


    }

 

View

 


              <?php echo validation_errors(); ?>
              <?php echo form_open('services/advisory'); ?>

                <table width="80%" border="0" cellspacing="2" cellpadding="0">
                  <tr>
                    <td align="right"> Title:</td>
                    <td><select name="title" id="title">
                      <option value="mr">Mr</option>
                      <option value="mrs">Mrs</option>
                      <option value="ms">Ms</option>
                    </select></td>
                  </tr>
                  <tr>
                    <td align="right">Surname:</td>
                    <td><input name="sname" type="text" id="sname" /></td>
                  </tr>
                  <tr>
                    <td align="right">First Name:</td>
                    <td><input name="fname" type="text" id="fname" /></td>
                  </tr>
                  <tr>
                    <td align="right">Email:</td>
                    <td><input name="email" type="text" id="email" /></td>
                  </tr>
                  <tr>
                    <td align="right">State:</td>
                    <td><input name="state" type="text" id="state" /></td>
                  </tr>
                  <tr>
                    <td align="right">Telephone</td>
                    <td><input name="tel" type="text" id="tel" /></td>
                  </tr>
                  <tr>
                    <td align="right">Topic:</td>
                    <td><select name="topic" id="topic">
                      <option value="0" selected="selected">Select Topic</option>
                      <option value="1">PAYE</option>
                      <option value="2">Capital Restructuring</option>
                    </select></td>
                  </tr>
                  <tr>
                    <td rowspan="2"> </td>
                    <td><textarea name="msg" id="msg"></textarea></td>
                  </tr>
                  <tr>
                    <td><input name="date" type="hidden" id="date" /></td>
                  </tr>
                  <tr>
                    <td> </td>
                    <td><input type="submit" name="Submit" value="Submit" /></td>
                  </tr>
                  <tr>
                    <td colspan="2"> </td>
                  </tr>
                </table>
              </form>  

 

thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.