Crud system
Hi sir?
i am new students of web. i have download the source code. its only view. it is not working as development. can u solve my problem
localhost/codeigniter_crud/
$config['base_url'] = 'http://localhost/codeigniter_crud/';
<?php class Users_model extends CI_Model { function __construct(){ parent::__construct(); $this->load->database(); } public function getAllUsers(){ $query = $this->db->get('users'); return $query->result(); } public function insertuser($user){ return $this->db->insert('users', $user); } public function getUser($id){ return $query->row_array(); } public function updateuser($user, $id){ $this->db->where('users.id', $id); return $this->db->update('users', $user); } public function deleteuser($id){ $this->db->where('users.id', $id); return $this->db->delete('users'); } } ?>
<?php class Users extends CI_Controller { function __construct(){ parent::__construct(); $this->load->helper('url'); $this->load->model('users_model'); } public function index(){ $data['users'] = $this->users_model->getAllUsers(); $this->load->view('user_list.php', $data); } public function addnew(){ $this->load->view('addform.php'); } public function insert(){ $user['username'] = $this->input->post('username'); $user['password'] = $this->input->post('password'); $user['fname'] = $this->input->post('fname'); $query = $this->users_model->insertuser($user); if($query){ } } public function edit($id){ $data['user'] = $this->users_model->getUser($id); $this->load->view('editform', $data); } public function update($id){ $user['username'] = $this->input->post('username'); $user['password'] = $this->input->post('password'); $user['fname'] = $this->input->post('fname'); $query = $this->users_model->updateuser($user, $id); if($query){ } } public function delete($id){ $query = $this->users_model->deleteuser($id); if($query){ } } } ?>
$route['default_controller'] = 'users';
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>CodeIgniter Simple CRUD Tutorial</title> <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>bootstrap/css/bootstrap.min.css"> </head> <body> <div class="container"> <h1 class="page-header text-center">CodeIgniter Simple CRUD Tutorial</h1> <div class="row"> <div class="col-sm-8 col-sm-offset-2"> <a href="<?php echo base_url(); ?>index.php/users/addnew" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> Add New</a><br><br> <table class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Username</th> <th>Password</th> <th>FullName</th> <th>Action</th> </tr> </thead> <tbody> <?php foreach($users as $user){ ?> <tr> <td><?php echo $user->id; ?></td> <td><?php echo $user->username; ?></td> <td><?php echo $user->password; ?></td> <td><?php echo $user->fname; ?></td> <td><a href="<?php echo base_url(); ?>index.php/users/edit/<?php echo $user->id; ?>" class="btn btn-success"><span class="glyphicon glyphicon-edit"></span> Edit</a> || <a href="<?php echo base_url(); ?>index.php/users/delete/<?php echo $user->id; ?>" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Delete</a></td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>CodeIgniter Simple CRUD Tutorial</title> <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>bootstrap/css/bootstrap.min.css"> </head> <body> <div class="container"> <h1 class="page-header text-center">CodeIgniter Simple CRUD Tutorial</h1> <div class="row"> <div class="col-sm-4 col-sm-offset-4"> <h3>Add Form <span class="pull-right"><a href="<?php echo base_url(); ?>" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-left"></span> Back</a></span> </h3> <hr> <form method="POST" action="<?php echo base_url(); ?>index.php/users/insert"> <div class="form-group"> <label>Username:</label> <input type="text" class="form-control" name="username"> </div> <div class="form-group"> <label>Password:</label> <input type="text" class="form-control" name="password"> </div> <div class="form-group"> <label>FullName:</label> <input type="text" class="form-control" name="fname"> </div> <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> Save</button> </form> </div> </div> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>CodeIgniter Simple CRUD Tutorial</title> <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>bootstrap/css/bootstrap.min.css"> </head> <body> <div class="container"> <h1 class="page-header text-center">CodeIgniter Simple CRUD Tutorial</h1> <div class="row"> <div class="col-sm-4 col-sm-offset-4"> <h3>Edit Form <span class="pull-right"><a href="<?php echo base_url(); ?>" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-left"></span> Back</a></span> </h3> <hr> <form method="POST" action="<?php echo base_url(); ?>index.php/users/update/<?php echo $id; ?>"> <div class="form-group"> <label>Username:</label> <input type="text" class="form-control" value="<?php echo $username; ?>" name="username"> </div> <div class="form-group"> <label>Password:</label> <input type="text" class="form-control" value="<?php echo $password; ?>" name="password"> </div> <div class="form-group"> <label>FullName:</label> <input type="text" class="form-control" value="<?php echo $fname; ?>" name="fname"> </div> <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-check"></span> Update</button> </form> </div> </div> </div> </body> </html>
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.