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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:39:23+00:00 2026-06-18T14:39:23+00:00

I am having trouble working with forms created using codeigniter. I have tried number

  • 0

I am having trouble working with forms created using codeigniter. I have tried number of ways to render a form on the webpage. But am unsuccessful at different points.

I am looking to render this

I tried to render a form with code:

<?php $this -> load -> helper('form');
    $formattr = array('id="form1"'); 
    form_open('registerUsr', $formattr);?>
        <fieldset>
            <legend>Registration Form</legend>
            <p class="first">
                <label for="firstName">First Name: </label>
                <input type="text" id="name" name="firstName" size="20" value="<?php echo set_value('first_name'); ?>" />
            </p>
        </fieldset>
        <p class="submit"><button type="submit" value="Submit" /></p>
<?php echo form_close(); ?>

I tried to create it using codeigniter functions

<?php echo form_open('registerUsr'); 
  echo form_input('$data'); 
  echo form_submit('submit', 'Submit'); 
  echo form_close();?>

I have tried hybrid variety using mix of html tags and helper class functions.

But in all the ways, on final render of the form on web page <form class=“form1”> tags are missing. And also instead of index.php/registerUsr, it is going into index.php/searchUniv page. (I have Checked routes config file. It is correctly pointed)

Any suggestions / ideas appreciated.

TIA 🙂

Update: Here is the controller and routes file

public function registration() {
        $this -> template -> title -> set('Register');
        $this -> template -> _content -> view('register_index', $overwrite = TRUE);
        $this -> template -> _sidebar -> view('gen_sidebar', $overwrite = TRUE);
        $this -> template -> publish();
    }

public function registerUsr(){
        $this -> template -> title -> set('Register');
        $searchItem = $this -> input -> post('form1');
        $this -> template -> publish();
    }
}

register_index.php is the code thats in the question which now looks okay.

$route['searchUniv']="sglobal/searchUniv";
$route['registration']="sglobal/registration";
$route['registerUsr']="sglobal/registerUsr";

template is the custom library i wrote which is working absolutely fine in all other pages. This application is in final stages, so I can say with 95% confidence, template is working okay. Also I am looking at the source of final rendered page and its exactly whats wanted. So, Can we look into any configurations before pointing at template.

Now the final render looks like:

<form action="http://localhost/univapp/index.php/registerUsr" method="post" accept-charset="utf-8" id="form1" class="form1">

but on submit its going to http://localhost/univapp/index.php/searchUniv

JUST FYI, I also have another search form on the same page (far away div, different id, different name, different class) which uses POST that points to index.php/searchUniv. Is there any problem because of that?

  • 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-06-18T14:39:24+00:00Added an answer on June 18, 2026 at 2:39 pm

    Try to avoid using Codeigniter helpers if they are not needed, html renders faster than php. All that’s required from the form helper is form_open() as this adds the csrf token.
    There also appears to be some typo’s in your code!

    Checklist:

    application/config/config.php

    $config['base_url'] = 'http://www.mysite.com/'; //I suspect this is your problem with routing
    $config['csrf_protection'] = TRUE;
    

    application/config/routes.php

    $route['register']  = 'controller/get_method'; //form
    $route['register/post'] = 'controller/post_method'; //validation
    

    views/registerUsr.php

    <?php if( validation_errors() ) : ?>
      <p class=error>Please Correct the Errors below</p>
    <?php endif; ?>
    
    <?=form_open('register/post', array('id'=>'', 'class'=>''))?>
    
    <fieldset>
        <legend></legend>
        <label for="firstname">
            <span class=required>*</span>
            First Name
            <small class=helper>Enter your First Name</small>
        </label>
        <input type=text id=firstname name=firstname value="<?=set_value('firstname')?>"/>
        <?=form_error('firstname')?>
    
        <button type=submit>Submit</button>
    </fieldset>
    
    <?=form_close()?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on a small blog form but have been having trouble with
I have a Windows Forms application that I'm working on, but I'm having trouble
My nested model form is now working, but I am having trouble displaying the
Im having trouble working grabbing a dynamically created image from this service: http://opsin.ch.cam.ac.uk/opsin/USER-STRUCTURE-TO-GENERATE.png Im
I'm having trouble getting Tire working using ElasticSearch with the Bonsai addon on the
I'm having trouble with getting a named scope working using using an attribute of
I'm having a bit of trouble finding an answer on this: Using Django forms,
I'm having trouble understanding the workings of Javascript...I want to pass a form name
I am having trouble working out how to get a simple fade in fade
I'm having trouble working out the best way to repaint a JxTreeTable 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.