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 4382182
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:44:45+00:00 2026-05-21T12:44:45+00:00

I have this code in the php file. it lists all the interests as

  • 0

I have this code in the php file. it lists all the interests as checkboxes and allows to input a text field “other”. The user should select several of these interests and save. Now, when the user clicks on the submit button it should take it to the controller and controller should extract them and store it in the database. I have one file thats coded to do that, but its no good and too confusing.

Here is the form in the normal php file

<form method="post" action="<?php echo site_url("userProfile/update_bio");?>" name="editForm" id="edit-form">

<div> <!-- description start -->
<div> <p <p class="special-p">Name:</p> <hr> </div>
<p class="used-p"> <input type="text" name="name" value="<?php echo $this->dx_auth->get_username(); ?>"></textarea> </p> <!-- should be real name -->

</div> <!-- description end -->

<div> <!-- description start -->
<div> <p <p class="special-p">Description:</p> <hr> </div>
<p class="used-p"> <textarea name="description"></textarea> </p>

</div> <!-- description end -->

<div> <!-- interests start -->
<div> <p class="special-p">Interests:</p> <hr class="special-hr2"> </div>
<p class="used-p">I am interested in:</p>

<ul>
<?php
foreach ($allInterests->result() as $row){
echo '<li><input type="checkbox" name="checks1[]" value="'.$row->id.'"/> '.$row->name.'</li>';


}

?>
<li><input type="checkbox" name="checks1[]" value="other"/> Other: <input type="text" name="otherText"/></li>
</ul>

</div> <!-- interests start -->

<div>
<input id="editbutton" type="submit" value="Save" name="editBioButton" class="small green button"/>
</div>

</form>

The controller function is empty. The problem is I don’t know how will it receive the checkboxes.

Thanx in advance

  • 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-21T12:44:46+00:00Added an answer on May 21, 2026 at 12:44 pm
    foreach($this->input->post(checks1) as $check)
    {
        echo $check;
    }
    

    But I believe that if the checkbox isn’t checked, it won’t appear in the $_POST array. To combat this, give each checkbox a specific index:

    <?php
    $count=0;
    foreach ($allInterests->result() as $row){
       echo '<li><input type="checkbox" 
            name="checks1[' . $count . ']" value="'.$row->id.'"/> '.$row->name.'</li>';
        $count++;
    }
    

    may do what you require. Your controller would be:

    foreach($this->input->post(checks1) as $key => $value)
    {
        echo $key . ' - ' . $value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.