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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:27:53+00:00 2026-05-26T23:27:53+00:00

I have a function to check if a credit card is valid or not.

  • 0

I have a function to check if a credit card is valid or not. If it is then continue to enter the details from the form into the database. But if it is not then display the message that is passed.

The problem is that if there is an issue with the credit card the message is passed but the rather then exiting the function so that it does not try to continue and add the data from the form, it adds the data.

I am not sure how to stop. The following code was written for me, seems to create a new dispatch and try to go back to the previous function confirm.

function confirm() {

    //This view contains the form, when user submits they go to checkout view
    if (isset($data)){$this->data = $data;}

    $this->set('redirect_to', 'checkout');  

}

function checkout(){

   if(!empty($this->data['User']['card_number'])){
        $check_card = $this->BillingValidation->validate_card($this->data['User']['card_number']);

        if($check_card['valid']!=false){
            // card is valid !

        } else {        
            $msg[0][] = $check_card['error'];
            $flashmsg = implode('<br />',$msg[0]).implode('<br />',$msg[1]);
                $this->Session->setFlash(__($flashmsg,
                          true),'default', array('class' => 'flash-message-success'));

            //if credit card is invalid go back to confirm view

            $this->autoRender = false;
            $d = new Dispatcher();
            $d->dispatch(array("controller" => "res", "action" => "confirm"),array("data" => $this->data));
        }
    } 
          //if credit card ok then continues to process form
}
  • 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-26T23:27:53+00:00Added an answer on May 26, 2026 at 11:27 pm

    I used exit() and that seemed to work

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

Sidebar

Related Questions

I am developing a form that allows users to enter their credit card information
I have a function to get the values of the selected check-box from the
I have used Javascript onlaod like this: function check() { var pic = new
Does R6RS or Chez Scheme v7.9.4 have a library function to check if a
Hey, so I have created a function to check the DB for unique entries,
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have a loop created with each, check this example: $('.foo').each(function(i){ //do stuff });
I have a HTML page, with html-mode enabled. I call function sgml-validate to check
I have a function that checks if a cookie (by name) exists or not:
I wanted to ask about using selector from a variable first I have: function

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.