• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Deleting users in an admin panel

#1
Hey guys 

New here not sure if this is the right place

But I have a function that needs to delete users from an admin panel 

My contoller function is this:

public function delete($id) {

        $this->admin_model->delete_user($id);
        redirect('/admin/users/');
    }

View looks like this:
 <?php foreach ($users as $user): ?>
                    <tr>
                        <td><?php echo $user['id']; ?></td>
                        <td><?php echo $user['email']; ?></td>
                        <td><?php echo $user['name']; ?></td>
                        <td><?php echo $user['username']; ?></td>
                        <td><?php echo $user['date_registered']; ?></td>
                        <td>
                            <a href="/admin/users/edit/<?php echo $user['id']; ?>" class="btn btn-primary btn-sm">Edit</a>
                            <a href="/admin/users/delete/<?php echo $user['id']; ?>"  class="btn btn-primary btn-sm">Delete</a>
                        </td>
                    </tr>
                <?php endforeach; ?>

Model: 
Nothing in the model

Im getting a 404 on the click of the button

I would love some help as im pretty stuck

Thanks
Reply

#2
Hi,

As i see your code, you need to define delete_user($id) function in admin_model.

feel free to ask if any query.

Good Luck !!!
Reply

#3
Have you set up a new route in config/routes.php?
Reply

#4
PHP Code:
/**
     * delete_user ()
     * --------------------------------------------------------------------
     *
     * @access    public
     * @param    $id
     */
    
public function delete_user($id)
    {
        
$this->db->delete('users', array('id' => $id));
    } 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.