01-09-2019, 03:32 AM
I have below file in views
<html>
<head>
<title>My Form</title>
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open('form'); ?>
<h5>Cert No.</h5>
<input type="text" name="certno" value="" size="20" />
<h5>Site Name</h5>
<input type="text" name="location" value="" size="20" />
<h5>Work Date</h5>
<input type="date" name="workdate" value="" size="10" />
<h5>Date Of Receipt</h5>
<input type="date" name="dateofreceipt" value="" size="10" />
<h5>Customer Name</h5>
<input type ="text" name="customername" value"" size="50"/>
</form>
</body>
</html>
And below in Controller:
<?php
class Form extends CI_Controller {
public function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}
}
With above I am able to create the form. Now I want to upload the data I entered in the form as per above to the mysql database (I have already created mysql databse & compatible table to suit above through PHPmyadmin).
Kindly suggest the required additional code in Controller, Model & View.
<html>
<head>
<title>My Form</title>
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open('form'); ?>
<h5>Cert No.</h5>
<input type="text" name="certno" value="" size="20" />
<h5>Site Name</h5>
<input type="text" name="location" value="" size="20" />
<h5>Work Date</h5>
<input type="date" name="workdate" value="" size="10" />
<h5>Date Of Receipt</h5>
<input type="date" name="dateofreceipt" value="" size="10" />
<h5>Customer Name</h5>
<input type ="text" name="customername" value"" size="50"/>
</form>
</body>
</html>
And below in Controller:
<?php
class Form extends CI_Controller {
public function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}
}
With above I am able to create the form. Now I want to upload the data I entered in the form as per above to the mysql database (I have already created mysql databse & compatible table to suit above through PHPmyadmin).
Kindly suggest the required additional code in Controller, Model & View.