Edit Data Code Igniter
created by sance ainul yakin
Controller/Edit,php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Edit extends CI_Controller {
public function index($id)
{
if($this->input->post('update')) {
$user=$this->input->post('user');
$pass=$this->input->post('pass');
$acc=$this->input->post('acc');
$jenkel=$this->input->post('jenkel');
$object=array(
'name'=>$user,
'password'=>$pass,
'access'=>$acc,
'jenkel'=>$jenkel
);
$this->db->where('id',$id);
$this->db->update('tb_login',$object);
//echo $this->db->affected_rows();
// if($this->db->affected_rows()){
// echo "Sukses";
// }
redirect('pageUser/index');
}else{
$data['data']=$this->tampil_model->prosesTampil();
$data['title']="Edit Data";
$data['editData']=$this->db->get_where('tb_Login',array('id'=>$id))->row();
$this->load->view('edit',$data);
}
}
public function editDatas($id=null)
{
}
}
view/edit.php
<!Doctype html>
<html>
<head>
<title><?php echo $title?></title>
<style>
#frm{
width:300px;
}
</style>
</head>
<body>
<div id="frm">
<form action="<?php echo site_url('edit/index').'/'.$editData->id;?>" method="POST">
<fieldset>
<legend>Edit Data</legend>
<input type="text" name="user" value="<?php echo $editData->name?>"/><br><br>
<input type="text" name="pass" value="<?php echo $editData->password?>"/><br><br>
<input type="text" name="acc" value="<?php echo $editData->access?>"/><br><br>
<label>Text Area</label><br><br>
<textarea name ="alamat"><?php echo $editData->access?></textarea><br><br>
<label>Jenis Kelamin : </label>
<select name="jenkel"><br><br>
<option value="Laki-Laki">Laki-Laki</option>
<option value="Perempuan">Perempuan</option>
</select><br><br>
<input type="submit" name="update" value="Update Data"><br><br>
</fieldset>
</form>
</div>
<?php echo print_r($editData)?>
</body>
</html>
GET VIDIO DOWNLOAD
Controller/Edit,php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Edit extends CI_Controller {
public function index($id)
{
if($this->input->post('update')) {
$user=$this->input->post('user');
$pass=$this->input->post('pass');
$acc=$this->input->post('acc');
$jenkel=$this->input->post('jenkel');
$object=array(
'name'=>$user,
'password'=>$pass,
'access'=>$acc,
'jenkel'=>$jenkel
);
$this->db->where('id',$id);
$this->db->update('tb_login',$object);
//echo $this->db->affected_rows();
// if($this->db->affected_rows()){
// echo "Sukses";
// }
redirect('pageUser/index');
}else{
$data['data']=$this->tampil_model->prosesTampil();
$data['title']="Edit Data";
$data['editData']=$this->db->get_where('tb_Login',array('id'=>$id))->row();
$this->load->view('edit',$data);
}
}
public function editDatas($id=null)
{
}
}
view/edit.php
<!Doctype html>
<html>
<head>
<title><?php echo $title?></title>
<style>
#frm{
width:300px;
}
</style>
</head>
<body>
<div id="frm">
<form action="<?php echo site_url('edit/index').'/'.$editData->id;?>" method="POST">
<fieldset>
<legend>Edit Data</legend>
<input type="text" name="user" value="<?php echo $editData->name?>"/><br><br>
<input type="text" name="pass" value="<?php echo $editData->password?>"/><br><br>
<input type="text" name="acc" value="<?php echo $editData->access?>"/><br><br>
<label>Text Area</label><br><br>
<textarea name ="alamat"><?php echo $editData->access?></textarea><br><br>
<label>Jenis Kelamin : </label>
<select name="jenkel"><br><br>
<option value="Laki-Laki">Laki-Laki</option>
<option value="Perempuan">Perempuan</option>
</select><br><br>
<input type="submit" name="update" value="Update Data"><br><br>
</fieldset>
</form>
</div>
<?php echo print_r($editData)?>
</body>
</html>
GET VIDIO DOWNLOAD
Edit Data Code Igniter
Reviewed by Leo
on
22:53
Rating:
No comments