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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:21:35+00:00 2026-05-15T21:21:35+00:00

Hi there I am having a problem with my form validation, basically the problem

  • 0

Hi there I am having a problem with my form validation, basically the problem is that I am getting a repeated view loaded if the validation fails, please see my code snippet,

else {
            //the user is a new customer so we need to show them 
            //the card details form
            $this->addViewData('returningCustomer', false);
            $this->load->library('form_validation');
            if($this->input->post('carddetails') == 'Submit') {
                $this->form_validation->set_rules('inpcardtype', 'Card type', 'cardTypeCheck'); //custom callback
                $this->form_validation->set_rules('inpcardnumber', 'Card number', 'required|trim|exact_length[16]');
                $this->form_validation->set_rules('startmonth', 'Start month', 'trim|required');
                $this->form_validation->set_rules('startyear', 'Start year', 'trim|required');
                $this->form_validation->set_rules('endmonth', 'End month', 'trim|required');
                $this->form_validation->set_rules('endyear', 'End year', 'trim|required');
                $this->form_validation->set_rules('inpissuenumber', 'Issue number', 'trim|integer');
                $this->form_validation->set_rules('inpccv', 'CCV Code', 'required|trim|exact_lenght[3]');
                if($this->form_validation->run() == FALSE) {
                    $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData);
                } else {
                    // validation is passed we need to safe the user details
                    // it is probable that we will need to hash the users card details
                    //@TODO: HASH USER CARD DETAILS LEAVE ONLY THE FINAL DIGITS
                    $this->load->model('checkout_model');
                }
            }
            $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData);

basically if a condtion fails futher up the script a view is loaded with a form, the form is submitted and if validation fails the user is passed back to the form but is show the errors, however the original view is also present. Can I stop it doing this?

  • 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-15T21:21:36+00:00Added an answer on May 15, 2026 at 9:21 pm

    After

    $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData);

    You should do return; as after the else statement theres another view loading.#

            //the user is a new customer so we need to show them 
            //the card details form
            $this->addViewData('returningCustomer', false);
            $this->load->library('form_validation');
            if($this->input->post('carddetails') == 'Submit') {
                $this->form_validation->set_rules('inpcardtype', 'Card type', 'cardTypeCheck'); //custom callback
                $this->form_validation->set_rules('inpcardnumber', 'Card number', 'required|trim|exact_length[16]');
                $this->form_validation->set_rules('startmonth', 'Start month', 'trim|required');
                $this->form_validation->set_rules('startyear', 'Start year', 'trim|required');
                $this->form_validation->set_rules('endmonth', 'End month', 'trim|required');
                $this->form_validation->set_rules('endyear', 'End year', 'trim|required');
                $this->form_validation->set_rules('inpissuenumber', 'Issue number', 'trim|integer');
                $this->form_validation->set_rules('inpccv', 'CCV Code', 'required|trim|exact_lenght[3]');
                if($this->form_validation->run() == FALSE) {
                    $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData);
                    return;// HERE
                } else {
                    // validation is passed we need to safe the user details
                    // it is probable that we will need to hash the users card details
                    //@TODO: HASH USER CARD DETAILS LEAVE ONLY THE FINAL DIGITS
                    $this->load->model('checkout_model');
                }
            }
            $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData);
            return;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Right click on each dataset file in solution explorer and… May 16, 2026 at 10:18 am
  • Editorial Team
    Editorial Team added an answer Unfortunately, the way you've described is the only way to… May 16, 2026 at 10:18 am
  • Editorial Team
    Editorial Team added an answer As far as efficiency is concerned both are interfaces so… May 16, 2026 at 10:18 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am wondering if anyone out there can help with my form Validation Please?
So I am having this problem wit my download link. Basically my previous way
I am using the jQuery validation plugin on my form. I set the basic
I'm using JQuery Validation to validate a particular textbox in my form. The textbox
I'm not really sure if there is a single problem here or I have
In one part of the application I'm working on, there is a form control
I have an ASP.NET MVC 2 form that is working perfectly, doing client side
I got the problem having written a little procedure to import some flatfiles in
I'm playing around with writing a jQuery plugin that uses an attribute to define
Is there any way to turn the damned error provider off when i try

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.