warning message in adding data that already input using codeigniter

Mark Daryl Senju Uchiiha

I have a problem in putting error message for the status of enrollment for student whether he/she Old Student, New Student, Transferee. When I input or add again the status of student, it will error due to duplicate entry because it is one-to-one relationship, so I need to set a message such as form validation but still it will error duplicate entry.

here is the picture: enter image description here

here is my controller:

function enrollstudent(){
        if($this->session->userdata('logged_in'))
        {
            
     $this->output->set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     $this->output->set_header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0');
     $this->output->set_header('Cache-Control: post-check=0, pre-check=0', FALSE);
     $this->output->set_header('Pragma: no-cache');
               $session_data = $this->session->userdata('logged_in');
           
            $data['Username'] = $session_data['Username'];
            $this->load->view('StudentEnroll', $data);
        } else{
            redirect('welcome', 'refresh');
        }
        if((!isset($session_data) || $session_data !=TRUE)) {
          
            redirect('welcome', 'refresh');
        }
    }
  

  function addstatusofenroll($id){
        
           $this->form_validation->set_rules('status', 'Status', 'callback_status_check');
 if($this->form_validation->run() == FALSE) 
        {
        $this->enrollstudent();}
        else{
              $data= array(
           'Id'=> $id ,
            'Statusofenrollment' => $this->input->post('status')
             
            
            
            );
              $this->db->insert('statusofenrollment',$data);
          
             $this->session->set_flashdata('category_success', 'Successfully Add!');
               $this->load->view('StudentEnroll');
                         }
                             
                         
    }
    
  

   public function callback_status_check($roll) 
    {
       $this->db->where('Id', $roll);
    $query = $this->db->get('statusofenrollment');
    $count_row = $query->num_rows();
    if ($count_row > 0) 
    {
        echo 'Data Already exist';
       $this->session->set_flashdata('warning', 'Data already exists');

              return FALSE;
    } 
    else 
    {
        return TRUE;
    }

       
    }

Gentle153

It sounds like the status shouldn't be a one-to-one relationship because there can be many students with the same status. If you change your database so the status field does not need to be unique, you should be able to insert and update each student freely.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Warning message using if function in data.table

From Dev

Adding a validation for an already existing data in my CodeIgniter application doesn't work

From Dev

Adding $data to view codeigniter

From Dev

Codeigniter Error Input data

From Dev

Input Multiple Data Codeigniter

From Dev

updating a warning message using jQuery

From Dev

How To Insert Data Using Multiple Input With Same Name in codeigniter

From Dev

How To Insert Data Using Multiple Input With Same Name in codeigniter

From Dev

How to access data Using the php://input stream in Codeigniter

From Dev

Warning message if file name already exists when creating a pdf file

From Dev

Yii2: disable warning log message "Session is already started"

From Dev

value already exist using bootstrapvalidation on codeigniter if value already exist

From Dev

Data loss warning adding column in the middle of a table

From Dev

Django messages - check if a message already exists before adding

From Dev

Warning message when using a big disk and iscsi

From Dev

Codeigniter data using into controller

From Dev

Adding Meta data to a codeigniter view from a controller

From Dev

R: Adding qualitative data using a text() argument to a for loop: unknown index type 'list' error message

From Dev

Adding data from a list to csv columns that already have data

From Dev

CodeIgniter: stream socket enable crypto SSL/TLS already set-up for this stream warning

From Dev

How to show success message using codeigniter?

From Dev

Dismissing a AlertDialog gives warning Attempted to finish an input event but the input event receiver has already been disposed

From Dev

Data check in database if already exist in codeigniter through ajax

From Dev

Adding a data member to an already existing class in C#

From Dev

Adding a data member to an already existing class in C#

From Dev

Adding data to database only when it is not already present (Node js)

From Dev

JQuery multiply input values and saving data (codeigniter)

From Dev

get input data to email function in codeigniter

From Dev

Parsing data to the view using codeigniter

Related Related

  1. 1

    Warning message using if function in data.table

  2. 2

    Adding a validation for an already existing data in my CodeIgniter application doesn't work

  3. 3

    Adding $data to view codeigniter

  4. 4

    Codeigniter Error Input data

  5. 5

    Input Multiple Data Codeigniter

  6. 6

    updating a warning message using jQuery

  7. 7

    How To Insert Data Using Multiple Input With Same Name in codeigniter

  8. 8

    How To Insert Data Using Multiple Input With Same Name in codeigniter

  9. 9

    How to access data Using the php://input stream in Codeigniter

  10. 10

    Warning message if file name already exists when creating a pdf file

  11. 11

    Yii2: disable warning log message "Session is already started"

  12. 12

    value already exist using bootstrapvalidation on codeigniter if value already exist

  13. 13

    Data loss warning adding column in the middle of a table

  14. 14

    Django messages - check if a message already exists before adding

  15. 15

    Warning message when using a big disk and iscsi

  16. 16

    Codeigniter data using into controller

  17. 17

    Adding Meta data to a codeigniter view from a controller

  18. 18

    R: Adding qualitative data using a text() argument to a for loop: unknown index type 'list' error message

  19. 19

    Adding data from a list to csv columns that already have data

  20. 20

    CodeIgniter: stream socket enable crypto SSL/TLS already set-up for this stream warning

  21. 21

    How to show success message using codeigniter?

  22. 22

    Dismissing a AlertDialog gives warning Attempted to finish an input event but the input event receiver has already been disposed

  23. 23

    Data check in database if already exist in codeigniter through ajax

  24. 24

    Adding a data member to an already existing class in C#

  25. 25

    Adding a data member to an already existing class in C#

  26. 26

    Adding data to database only when it is not already present (Node js)

  27. 27

    JQuery multiply input values and saving data (codeigniter)

  28. 28

    get input data to email function in codeigniter

  29. 29

    Parsing data to the view using codeigniter

HotTag

Archive