Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7170261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:10:31+00:00 2026-05-28T15:10:31+00:00

I have a dialog form. <div id=dialog-form title=Create new Admin> <p class=validateTips>All form fields

  • 0

I have a dialog form.

 <div id="dialog-form" title="Create new Admin">
<p class="validateTips">All form fields are required.</p>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<fieldset>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" value="" class="text ui-widget-content ui-corner-all" />
    <label for="role">Role</label>
    <select name="user_role" class="select ui-widget-content ui-corner-all" >
    <option value="administrator">Administrator</option>
    <option value="visitor">Visitor</option>
    <option value="Helper">Helper</option>
    </select>
    <label for="email">Email</label>
    <input type="text" name="login_email_admin" id="login_email_admin" value="" class="text ui-widget-content ui-corner-all" />
    <label for="Passoword">Password</label>
    <input type="passowrd" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
    <label for="Passoword">Re-Enter Password</label>
    <input type="password" name="password_2" id="password_2" value="" class="text ui-widget-content ui-corner-all" />

    <input style="margin-top:15px;" type="submit" name="add_admin" value="Add New Admin">
</fieldset>
</form>

i am using following php code in views to take data from this dialog form when it will be submitted..

 <?php 

    if($_POST['add_admin'])
    {

    $this->user_role=$this->input->post('name');
    $this->user_role=$this->input->post('user_role');
    $this->login_email_admin=$this->input->post('login_email_admin');
    $this->password=$this->input->post('password');

    $this->load->database();
    $this->db->insert('admin_user',$this);
    }

?>

But it’s not inserting into the db.this problem really stuck me.i am calling page itself when form submit, i dont know what is the reason its not working.
additionally is there a way that i will get rid of using models, instead i can do all db operations in views?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:10:32+00:00Added an answer on May 28, 2026 at 3:10 pm

    This code is wrong in many aspects:

    if($_POST['add_admin'])
        {
    
        $this->user_role=$this->input->post('name');
        $this->user_role=$this->input->post('user_role');
        $this->login_email_admin=$this->input->post('login_email_admin');
        $this->password=$this->input->post('password');
    
        $this->load->database();
        $this->db->insert('admin_user',$this);
        }
    
    1. You’re overwriting the user_role property;
    2. you’re passing the whole $this reference, which contains way much more than those properties
    3. that’s not how you do an insert with Active Record! Field names must be passad as an array, not as object properties

    Should be something like:

    $field['user'] = $this->input->post('name'); //or whatever is the FIELD NAME
    $field['user_role'] = $this->input->post('user_role');
    $field['login_email_admin'] = $this->input->post('login_email_admin');
    $field['password'] = $this->input->post('password');
    $this->load->database();
    $this->db->insert('admin_user',$field);
    

    See insert chapter on manual for reference.

    Also, I don’t know why you want to do that inside a view, you should do the insert in a model, and the checking for the form being submitted must be done in the controller (ideally you could use the Form Validation class, which is very handy for this task.

    You’re using a framework with an MVC architecture but in this piece of code you’re taking advantage of almost nothing from both…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form: <div id=dialog class=event-dialog title=Create Event> <div id=dialog-inner> <table> <tr><td
I have such a form <form name= method=post action=Save enctype=multipart/form-data> <div id=dialog title=Upload files>
I have the following form declaration: <div class=edit-dialog span-10 style=display:none;> <div class=edit-message span-10 style=margin-bottom:30px;>
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have a jQuery dialog. All of the fields are posting correctly except for
I'm using Facebox for my dialog boxes. And I have a create form inside
I have a form to perform uploads: <%= form_tag({:controller => assets, :action => create,
I have a form and from this I call dialogPrintDiet.ShowDialog() which launchs my dialog.
I have a jquery ui dialog with a knockoutjs submit binding on a form.
I have code that opens a dialog, validates, and posts a form when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.