Welcome Guest, Not a member yet? Register   Sign In
Credit Card Processing / Validation
#2

[eluser]Pascal Kriete[/eluser]
Something like this might work:
Code:
$this->load->library('validation');
        
    $rules['username']    = "required";
    //... and any other rules
    
    $this->validation->set_rules($rules);
    
    $fields['username']    = 'Username';
    //... ditto here

    $this->validation->set_fields($fields);

    if($this->validation->run() == TRUE)
    {
        $credit_card_ok = //check the credit card

        if (count($_POST) > 1 && $credit_card_ok)
        {
            //redirect, success message, shutdown site now that you have the money, etc
        }
        else
        {
            // Form was good, but the credit card didn't come back positive.
            $this->validation->error_string = "Credit card invalid."
            $this->load->view('form_view');
        }
    }
    else
    {
        // First load, and if the form wasn't good.
        $this->load->view('form_view');
    }

This should refill the form and bypass your multiple credit card checks issue. Not the most elegant solution though.

To refill the form just do it the normal way with:
Code:
<?=$this->validation->fieldname;?>
Remember to run set_fields for this to work.

EDIT: The reason why this works is because CI runs set_fields before deciding on true or false. So even if the form validates, the object is already set...or so I hope (didn't test it Smile ).


Messages In This Thread
Credit Card Processing / Validation - by El Forum - 03-31-2008, 02:53 PM
Credit Card Processing / Validation - by El Forum - 03-31-2008, 04:02 PM
Credit Card Processing / Validation - by El Forum - 03-31-2008, 06:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB