Is it possible to get data from file then add it in my database in mysql. I'm using codeigniter. My code only asks inputs from the user. Please help please. It is required by my professor so that if the user wants to input for example 100 data he/she doesn't manually input the data thus get the data from another database.
my view page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Students</title>
</head>
<body>
<div id="container">
<h1>Student's Page</h1>
<div id="body">
<div id="div2">
<?php
echo form_open('main/addToRegistrar');
?>
<br>
<?php
echo "<p>ID: ";
echo form_input('id');
echo "</p>";
echo "<p>First Name: ";
echo form_input('first_name');
echo "</p>";
echo "<p>Middle Name: ";
echo form_input('middle_name');
echo "</p>";
echo "<p>Last Name: ";
echo form_input('last_name');
echo "</p>";
echo "<p>";
echo form_submit('ADD', 'ADD');
echo "<p>";
echo form_close();
?>
<a href='<?php echo base_url()."main/admin"; ?>'>Home!</a>
</div>
</div>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds </p>
</div>
</body>
</html>
my controller
public function addToRegistrar(){
if($this->session->userdata('is_logged_in')){
$this->load->model('model_users');
$this->model_users->addToRegistrar();
$this->load->view('view_addAteneoStudents');
} else{
redirect('main/restricted');
}
}
my model
public function addToRegistrar(){
$fname = $this->input->post('first_name');
$mname = $this->input->post('middle_name');
$lname = $this->input->post('last_name');
$id = $this->input->post('id');
$data = array(
'id' => $id,
'first_name' => $fname ,
'middle_name' => $mname ,
'last_name' => $lname
);
if($this->db->insert('registrar', $data)){
echo "Successfully added";
}
}