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

  • Home
  • SEARCH
  • 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 7648713
In Process

The Archive Base Latest Questions

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

I have made a site in CodeIgniter2, but I can’t get the forms to

  • 0

I have made a site in CodeIgniter2, but I can’t get the forms to work, as I can’t seem to even work out how to get it to post! Any help? Here is my code and the forms are only on the recommend, contact-us and support pages:

Form:

<div id="mainWhiteBox">
        <h3>Tell people about us...</h3>
        <p>If you know of a company or individual who need a really great design agency to help them with a project, let them know about us and benefit too. <br /><br />
        <span class="customColour">We will give you &pound;50 of Marks &amp; Spencer vouchers for every client you recommend to us who goes on to become a client of xxxxx, it's that simple &amp; there is no limit to the amount of vouchers you can earn!</span></p>
        <div id="recommendSomeone">
            <?php echo validation_errors(); print_r($_POST);?>
            <?php echo form_open('recommend', array('id' => 'recommendForm')); ?>
                <label for="friendName">Your Friend's Name</label>
                <input type="text" id="friendName" value="<?php echo set_value('friendName'); ?>" />
                <label for="friendEmail">Your Friend's Email Address</label>
                <input type="email" id="friendEmail" value="<?php echo set_value('friendEmail'); ?>" placeholder="someone@youknow.com" />
                <label for="customerName">Your Name</label>
                <input type="text" id="customerName" value="<?php echo set_value('customerName'); ?>" />
                <label for="customerEmail">Your Email Address</label>
                <input type="email" id="customerEmail" value="<?php echo set_value('customerEmail'); ?>" placeholder="you@youremailaddress.com" />
                <label for="friendConfirm"><input type="checkbox" id="friendConfirm" value="1" <?php echo set_checkbox('friendConfirm', '1'); ?> />I confirm that I know the person I am recommending above.</label>
                <input type="submit" value="Submit Recommendation" />
            </form>
            <img src="<?=base_url(); ?>images/uploads/<?php echo $images[0]["image_filename"]; ?>" alt="<?php echo $images[0]["image_alt"]; ?>" width="180px" height="300px" class="floatRight" />
        </div>
        <p class="elevenFont">* Get &pound;50 of Marks &amp; Spencer vouchers per company or person recommended who goes on to open an account with xxxxx.</p>
    </div>
    <?php include("/home/xxxxx/libraries/application/views/widgets/newsWidget.php"); ?>
    <?php include("/home/xxxxx/libraries/application/views/widgets/twitterWidget.php"); ?>
    <?php include("/home/xxxxx/libraries/application/views/widgets/quickViewWidget.php"); ?>
    <?php include("/home/xxxxx/libraries/application/views/widgets/fbLikePageWidget.php"); ?>
    <?php include("/home/xxxxx/libraries/application/views/widgets/getQuoteBarWidget.php"); ?>
    <?php include("/home/xxxxx/libraries/application/views/widgets/newsletterSubscribeWidget.php"); ?>

Controller:

<?php

class Pages extends CI_Controller {

public function __construct()
{
    parent::__construct();
    $this->load->model('pages_model');
}


public function view($page = 'home')
{

    if ( ! file_exists('/home/urbanfea/libraries/application/views/pages/'.$page.'.php'))
    {
        // Whoops, we don't have a page for that!
        show_404();
    }       

    $data['title'] = $this->pages_model->getTitle($page);
    $data['showcase'] = $this->pages_model->getShowcase();
    $data['news'] = $this->pages_model->getNewsWidgetContent();
    $data['quote'] = $this->pages_model->getQuoteFromBank();
    $data['images'] = $this->pages_model->getPageImageArray($page);
    $data['PageStraplines'] = $this->pages_model->getStraplines($page);
    $data['serverStatus'] = $this->pages_model->getIssue("1");

    if($page == "support")
    {
        $this->load->view('templates/supportHead', $data);
    }
    else
    {
        $this->load->view('templates/head', $data); 
    }

    if($page == "recommend" || $page == "contact-us" || $page == "support")
    {
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');

        $this->form_validation->set_rules('friendName', 'Friend\'s Name', 'required');
        $this->form_validation->set_rules('friendEmail', 'Friend\'s Email Address', 'required');
        $this->form_validation->set_rules('customerName', 'Customer\'s Name', 'required');
        $this->form_validation->set_rules('customerEmail', 'Customer\'s Email Address', 'required');
        //$this->form_validation->set_rules(FriendConfirm', 'Confirm you know the person', 'required');

        if ($this->form_validation->run() === true)
        {
            $this->load->view('templates/formSuccess', $data); echo "a";
        }
        elseif($this->form_validation->run() === false && validation_errors() != "")
        {
            $this->load->view('templates/formError', $data); echo "b";
        }
        elseif($this->form_validation->run() === false)
        {
            echo "c";
        }

    }

    $this->load->view('templates/header', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);

}

}

?>

Edit

Here are the routes in my router:

$route['404_override'] = '';

$route['user/(:any)'] = 'user/view/$1';
$route['user'] = 'user/login';
$route['our-work/(:any)'] = 'our_work/view/$1';
$route['our-work'] = 'our_work';
$route['what-we-do/(:any)'] = 'what_we_do/view/$1';
$route['what-we-do'] = 'what_we_do';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
  • 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-31T10:47:11+00:00Added an answer on May 31, 2026 at 10:47 am

    Your form_open function echo form_open('recommend', array('id' => 'recommendForm')); will create the following output: <form method="post" accept-charset="utf-8" action="http:/example.com/index.php/recommend" />

    This is looking for a controller called recommend, which I don’t think is what you want. Change the form_open function so it directs your form to the proper controller/action.

    Also, it doesn’t look like your code is taking full advantage of the MVC framework. Instead of handling passing everything through the same controller/function and having all those if statements to load different views based on what $page is, you should have separate functions for each of those views.

    EDIT:
    Your form input elements are missing the name attribute. They must have the name attribute to be accessible through $_POST. Take a look at this page in the Codeigniter help. Maybe make use of the form_input function to generate the input fields?

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

Sidebar

Related Questions

Post-release, I have made one small change to one form in our development site
Hi I made this site a while ago in my table days but have
I have made most my site SE friendly, but one part of my site
I have made the following search script but can only search one table column
i have made a static site with only html static pages but now i
I have made a site with classic php and mysql functions. I order to
I have a site I made really fast that uses floats to display different
I currently have a community site that I run that is made up of
I have made a custom UserControl i Vb.net (windows application). How can I add
I have made a site in SharePoint Foundation 2010. I used team site as

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.