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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:33:01+00:00 2026-05-24T04:33:01+00:00

Possible Duplicate: How to access a variable in a PHP class that is set

  • 0

Possible Duplicate:
How to access a variable in a PHP class that is set by another function? Codeigniter

I have a controller called submit:

Basically it does two things of concern:

  1. validate_form() – It validates a form -> then submits to
    database.
  2. success() – It loads a page giving feedback on whether the
    previous operation was successfull.

My controller works fine however there is a slight problem in when it loads my success page.
If you hit Refresh the “success” page it would for some reason cause my validate_form() function to run again causing the same data to be duplicated in the database.

What I want is that when the user goes to success page they can hit refresh as many times they like and it wont call any functions etc.

My url on the success view is

http://localhost/site/validate_form

I am guessing this is the problem because it is still in the validate_form() function.

My validate form function loads the success view by calling another function within it?
Here is my code:

//Record ID = returned value
                        $record_id = $this->submit_model->create_record($completedstaffrows, $completedeventrows);

                        //if no value returned call failed function

                        if ($record_id == FALSE)
                        {
                            $this->failed();
                        }

                        //Submittal to database was successful
                        //Now call function to load success view
                        else
                        {

                            $this->success();
                        }

My function for loading success view:

    public function success()
        {
            $page['page'] = 'success';

            $this->load->view('template', $page );

        }
  • 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-24T04:33:02+00:00Added an answer on May 24, 2026 at 4:33 am

    What you need is a Post/Redirect/Get pattern. After the form is submitted, make a 301 redirect to the same page, maybe with a session variable to know whether the data was valid or not, and this would prevent any duplicate data issue on refresh.

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

Sidebar

Related Questions

Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the
Possible Duplicate: Best way to stop SQL Injection in PHP I am creating a
Possible Duplicate: How can I access local scope dynamically in javascript? Hi all. We
Possible Duplicate: before_filter :require_owner I am trying to restrict access to certain actions using
Possible Duplicate: How to access java-classes in the default-package? I am using Eclipse 3.5
Possible Duplicate: Check if access table exists I'm new to vba macros. Any idea
Possible Duplicate: Any way to access array directly after method call? In C# and
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is 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.