I have a link which when clicked passes an argument to my controller to a function like so:
/home/inquire/54
- I want to then load a view which has a form in it and gather some input data.
- I then want to email both the argument and the form data to myself
This is my controller:
public function inquire($id) {
$this->form_validation->set_rules('inputName', 'Name', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('client/M_inquire.php');
} else {
$this->email->from('noreply@test.com', 'System');
$this->email->to('contactus@test.com');
$this->email->subject('New Client Registration');
$this->email->message(
"Name: " . $this->input->post('inputName') . "<br />" .
"Phone: " . $this->input->post('inputPhone') . "<br />" .
"Email: " . $this->input->post('inputEmail') . "<br />" .
"Nurse profession: " . $this->input->post('inputProfession') . "<br />" .
"Nurse ID: " . $nurseid
);
$this->email->send();
$this->load->view('client/M_inquire_success.php');
}
}
THis is my view:
<?php echo form_open('home/inquire'); ?>
<label>Full Name</label>
<input type="text" name= "inputName" id="inputName">
The problem is the controller expects an argument so when the form opens it crashes. Any idea how I can maintain the first argument I passed and gather some form data and email both?
THanks a lot.
In your call to
form_openin your view you can append theid.So, in your controller you could have something like:
and then in the view you have: