Welcome Guest, Not a member yet? Register   Sign In
how to enter data into the database via forms simultaneously???
#1

[eluser]dinnar[/eluser]
how to enter data into the database via forms simultaneously???


help me...
#2

[eluser]Sudz[/eluser]
Specify your Problem correctly.
Exactly what do you want to do?
#3

[eluser]dinnar[/eluser]
I want to make 2 pieces of the form, the first form that contains a textbox with a submit button, if I fill in the numbers in the form of the number of rows in the second form will be as much as the numbers I entered. eg I enter 5 on Form1 it will display 5 lines of textbox on form2
#4

[eluser]Sudz[/eluser]
use jquery for that.
And post your problem clearly so that every one can understand.
#5

[eluser]dinnar[/eluser]
i make 4 file namely form.php(view), submit.php(view), simultan.php(controller), simultan_model(model). my problem is why data I fed not enter to database????

help me..........


U can see the file below:

form.php:
<form name="input_form" method="post" action="<?php echo $form_action; ?>">
<label for="jum">Jumlah Record:</label>
&lt;input type="text" name="jum" size="10" class="form_field"
value="&lt;?php echo set_value('jum');?&gt;"/&gt;
&lt;?php echo form_error('jum', '<p class="field_error">', '</p>');?&gt;

<p>
&lt;input type="submit" name="submit" value="Proses"/&gt;
</p>


submit.php:
&lt;/form&gt;
&lt;form name="submit_form" method="post" action="&lt;?php echo $form_action;?&gt;"&gt;
&lt;?php
$n = $this->input->post('jum');
$i=1;
?&gt;
<table>
<tr>
<td> Nim</td>
<td> Nama</td>
</tr>
&lt;?php
for($i=1; $i<=$n; $i++){
echo "<tr><td> &lt;input type='text' name='nim".$i."' size='5' /&gt;&lt;/td>
<td> &lt;input type='text' name='nama".$i."' size='5'/&gt;&lt;/td></tr>";
}
?&gt;
</table>
<p>
&lt;input type="submit" name="submit" value="Simpan"/&gt;
</p>
&lt;/form&gt;

simultan.php:
function index(){
$this->form();
}

function form(){
$data['title'] = $this->title;
$data['h2_title'] = 'Input Data';
$data['main_view'] = 'form';
$data['form_action'] = site_url('simultan/add');

if($this->form_validation->run() == TRUE){
$n = $this->input->post('jum');
$this->session->set_userdata($n);
redirect('simultan/add');
}else{
$this->load->view('template', $data);
}
}

function add(){
$data['title'] = $this->title;
$data['h2_title'] = 'Input Data';
$data['main_view'] = 'submit';
$data['form_action'] = site_url('simultan/add_process');
$data['link'] = array('link_back'=> anchor('simultan/', 'kembali', array('class'=>'back')));

$this->load->view('template', $data);
}

function add_process(){
$data['title'] = $this->title;
$data['h2_title'] = 'Input Data';
$data['main_view'] = 'submit';
$data['form_action'] = site_url('simultan/add_process');
$data['link'] = array('link_back'=> anchor('simultan/', 'kembali', array('class'=>'back')));


if($this->form_validation->run() == TRUE){
$n = $this->input->post('jum');

for($i=1; $i<=$n; $i++){
$datanim = $this->input->post('nim".$i."');
$datanama = $this->input->post('nama".$i."');



}
$mhs = array('nim'=>$datanim, 'nama'=>$datanama);

$this->simultanmodel->add($mhs);
$this->session->set_flashdata('message', 'Data berhasil disimpan');
redirect('simultan/add');
}else{
$this->load->view('template', $data);
}
}

simultan model:
function add($mhs){
$this->db->insert($this->table, $mhs);
}
#6

[eluser]Unknown[/eluser]
Dinnar, I think that php forms will help you. It is a program that will help you to create any kind of web form, and it will not contain any bug. Also there you can find a tutorial, that will help you to solve some of your problems.
Good luck!
#7

[eluser]dinnar[/eluser]
thx guys,i have solve the problem




Theme © iAndrew 2016 - Forum software by © MyBB