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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:51:53+00:00 2026-06-16T19:51:53+00:00

need help on this one: here’s a my sample code, i would like to

  • 0

need help on this one:

here’s a my sample code,
i would like to add a validation message if a preg_match occurs:
pls. see inline comments for more details..

public function supplier_entry()
{
    if (preg_match("/[\'^£@&*...etc.../", $this->input->post('supplier')))
    {  

    //add or pass validation message, ex. $msg = 'Invalid Supplier Name';  
    // i tried $this->supplier_entry_form($msg); but its not working.  

        $this->supplier_entry_form();

    }else{
        $post_data = array(
        'supplier_name' =>$this->input->post('supplier'),
        'user' => $this->input->post('user'),       
        'trx_id' =>$this->input->post('trx_id'),
        );  

        $this->load->model('user_model');
        $this->load->model('product_model');

        $this->product_model->add_new_supplier($post_data);
        $user_data['trx'] = 'Supplier Entry';
        $user_data['username'] = $this->user_model->user_info();
        $trx_data['supplier'] = $this->product_model->get_supplier_list();  
        $trx_data['msg'] = 'Supplier Posted.';  


        $this->load->view('header',$user_data);     
        $this->load->view('item_supplier', $trx_data);              
    }
}  

thanks in advance..

    public function supplier_entry_form()
{
    $this->load->model('user_model');
    $this->load->model('product_model');

    $user_data['username'] = $this->user_model->user_info();
    $user_data['trx'] = 'Supplier Entry';   
    $trx_data['supplier'] = $this->product_model->get_supplier_list();

    $this->load->view('header', $user_data);                      
    $this->load->view('item_supplier', $trx_data);
}
  • 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-06-16T19:51:54+00:00Added an answer on June 16, 2026 at 7:51 pm

    Use the built in form validation.

    $this->load->library('form_validation');
    $this->form_validation->set_rules($this->input->post('supplier'), 'Supplier', 'trim|callback_pregMatchSupplier');
    if($this->form_validation->run()==FALSE)
    {
        $this->supplier_entry_from();
    }
    // continue code here if validation passes.
    
    
    function pregMatchSupplier()
    {
        if (preg_match("/[\'^£@&*...etc.../", $this->input->post('supplier')))
        {
           return FALSE;
        } else {
           return TRUE;
        }
    

    Then in the view you echo out the validation errors:

    <?php echo validation_errors(); ?>
    

    http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html

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

Sidebar

Related Questions

I really need help on this one. I am having a simple login form
I need your help with this one again. I want to send special characters
We Really need some help on this one: We've Struggled with all the Apple
Okay, I need help. I'm usually pretty good at SQL queries but this one
I need a regex expert to help out on this one. Examples I've found
I need help with one ajax function This is raw page setup. Page will
I desperately need some help on this one. I've created a <script> that closely
sorry if you'll find this question stupid, but I really need help. Here's some
Please I really need help on this one... I have 2 Forms Form1 and
i need help with this JQuery code i have.. i'm still a newbie when

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.