[eluser]ibnclaudius[/eluser]
Are there any other field that is being sent correctly?
[eluser]the_unforgiven[/eluser]
yes and sent to a controller function that is then sent to a model function tio insert in the db
Code: Edit Client Form
<fieldset id="signin_menu">
<?php
$attributes = array('class' => 'email', 'id' => 'loginform');
echo form_open('admin/createmeeting', $attributes);
echo form_hidden('CustomerID', $meeting->CustomerID); // THIS IS WHAT I NEED TO GET TO THE DB
$date = array('name' => 'MeetingDate', 'id' => 'date');
$client = array(
'name' => 'CustomerID',
'value' => $query->Contact1,
'readonly' => 'readonly'
);
?>
<table>
<tr><td>Date:</td><td><?php echo form_input($date); ?></td><td><small>Format: (month-day-year)</small></td></tr>
<tr><td>Client:</td><td><?php echo form_input($client); ?></td><td>ClientID:</td><td><?php echo $meeting->CustomerID ?></td></tr>
<tr><td>Remarks:</td><td><?php echo form_textarea('Remarks'); ?></td></tr>
<tr><td>Cuttings:</td><td><?php echo form_textarea('Cuttings'); ?></td></tr>
<tr><td>Date Entered:</td><td><strong><?php echo $query->DateEntered; ?></strong></td></tr>
</table>
<?php echo form_submit('submit', 'Create New Meeting'); ?>
<?php echo form_close();?>
</fieldset>
Code: Controller
function createmeeting()
{
// Form Validation
$this->form_validation->set_rules('Date', 'Date', 'required');
$this->form_validation->set_rules('Remarks', 'Remarks', 'required');
$this->form_validation->set_rules('Cuttings', 'Cuttings', 'required');
if ($this->form_validation->run() == FALSE)
{
// Activate the add meeting model
$this->meeting_model->addNewMeeting();
}
else {
echo 'Something wasnt right';
}
}
Code: Model
function addNewMeeting()
{
$meeting = $this->getMeetingRows();
$data = array(
//'CustomerID' => $meeting['CustomerID'],
'CustomerID' => $this->input->post('CustomerID'),
'AgencyID' => $this->input->post('AgencyID'),
'MeetingDate' => $this->input->post('MeetingDate'),
'Remarks' => $this->input->post('Remarks'),
'Cuttings' => $this->input->post('Cuttings'),
'DateEntered' => now()
);
$this->db->insert('tblmeeting', $data);
$d['meeting'] = $this->session->set_flashdata('meeting', 'The meeting has been successfully saved');
redirect('admin/updateclient/'.$meeting['CustomerID'], $d);
}
[eluser]the_unforgiven[/eluser]
This is the view source:
Code: <fieldset id="signin_menu">
<form action="http://localhost/ksd/admin/createmeeting" method="post" accept-charset="utf-8" class="email" id="loginform">
<input type="hidden" name="CustomerID" value="3198" /> <!-- See the Customer ID is there-->
<table>
<tr><td>Date:</td><td><input type="text" name="MeetingDate" value="" id="date" /></td><td><small>Format: (month-day-year)</small></td></tr>
<tr><td>Client:</td><td><input type="text" name="CustomerID" value="MR Webber" readonly="readonly" /></td><td>ClientID:</td><td>3198</td></tr>
<tr><td>Remarks:</td><td><textarea name="Remarks" cols="40" rows="10" ></textarea></td></tr>
<tr><td>Cuttings:</td><td><textarea name="Cuttings" cols="40" rows="10" ></textarea></td></tr>
<tr><td>Date Entered:</td><td><strong>1999-03-19 18:41:12</strong></td></tr>
</table>
<input type="submit" name="submit" value="Create New Meeting" /> </form> </fieldset>
[eluser]ibnclaudius[/eluser]
Set $data in controller, and then send it to the model.
Code: $data = array(
//'CustomerID' => $meeting['CustomerID'],
'CustomerID' => $this->input->post('CustomerID'),
'AgencyID' => $this->input->post('AgencyID'),
'MeetingDate' => $this->input->post('MeetingDate'),
'Remarks' => $this->input->post('Remarks'),
'Cuttings' => $this->input->post('Cuttings'),
'DateEntered' => now()
);
$this->meeting_model->addNewMeeting($data);
Code: function addNewMeeting($data)
[eluser]the_unforgiven[/eluser]
i get
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: controllers/admin.php
Line Number: 355
[eluser]ibnclaudius[/eluser]
You tried this?
Code: function createmeeting()
{
// Form Validation
$this->form_validation->set_rules('Date', 'Date', 'required');
$this->form_validation->set_rules('Remarks', 'Remarks', 'required');
$this->form_validation->set_rules('Cuttings', 'Cuttings', 'required');
if ($this->form_validation->run() == FALSE)
{
$data = array(
//'CustomerID' => $meeting['CustomerID'],
'CustomerID' => $this->input->post('CustomerID'),
'AgencyID' => $this->input->post('AgencyID'),
'MeetingDate' => $this->input->post('MeetingDate'),
'Remarks' => $this->input->post('Remarks'),
'Cuttings' => $this->input->post('Cuttings'),
'DateEntered' => now()
);
$this->meeting_model->addNewMeeting($data); // <= HERE!
}
else {
echo 'Something wasnt right';
}
}
Code: function addNewMeeting($data) // <= HERE!
{
$meeting = $this->getMeetingRows();
$this->db->insert('tblmeeting', $data);
$d['meeting'] = $this->session->set_flashdata('meeting', 'The meeting has been successfully saved');
redirect('admin/updateclient/'.$meeting['CustomerID'], $d);
}
[eluser]the_unforgiven[/eluser]
Yes thats exactly what ive done
[eluser]ibnclaudius[/eluser]
Try this, and show me what you got:
Code: function createmeeting()
{
// Form Validation
$this->form_validation->set_rules('Date', 'Date', 'required');
$this->form_validation->set_rules('Remarks', 'Remarks', 'required');
$this->form_validation->set_rules('Cuttings', 'Cuttings', 'required');
if ($this->form_validation->run() == FALSE)
{
$data = array(
//'CustomerID' => $meeting['CustomerID'],
'CustomerID' => $this->input->post('CustomerID'),
'AgencyID' => $this->input->post('AgencyID'),
'MeetingDate' => $this->input->post('MeetingDate'),
'Remarks' => $this->input->post('Remarks'),
'Cuttings' => $this->input->post('Cuttings'),
'DateEntered' => now()
);
var_dump($data);
}
else {
echo 'Something wasnt right';
}
}
[eluser]the_unforgiven[/eluser]
Heres the output
Code: array(6) { ["CustomerID"]=> string(16) "MR Webber" ["AgencyID"]=> bool(false) ["MeetingDate"]=> string(10) "01/01/1888" ["Remarks"]=> string(16) "is trhis working" ["Cuttings"]=> string(25) "kjhsfkjh dflkjd flkjd fdf" ["DateEntered"]=> int(1328049108) }
[eluser]ibnclaudius[/eluser]
Change:
For:
Code: $this->meeting_model->addNewMeeting($data);
Add this right after defining the class of your controller:
Now, try to run...
|