PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 5, 2022

[FIXED] insert url parameter in mysql with codeigniter

 March 05, 2022     codeigniter, codeigniter-3, frameworks, model-view-controller, php     No comments   

Issue

I need your help!

I am new to codeigniter and I am trying to pass a fetch parameter from url, get me the value using the following

My example url is the following: http://localhost/infocargacasosfinal/index.php/creacionacta/?NroGestion=1&NroContacto=103386816

Where what I am rescuing is the value "NroContacto", I have managed to bring me the value with the following line in the controller:

'NroContacto' => $this->input->get('NroContacto');

and show it in the view with the following:

                        <td>
                                          Numero Folio:   <?php echo $nrocontacto; ?> 
                    </td>

that way I have managed to show it in the user's view, but now I can't find a way to save that value in the database when the user clicks the "save" button


Solution

You have not shared much information related to your issue. I am assuming that you need two server calls to save the URL parameter into data.

  1. First "http://localhost/infocargacasosfinal/index.php/creacionacta/?NroGestion=1&NroContacto=103386816", is used to render the page with a form to submit.
  2. Second, When the user clicks the submit button in the form, data is stored in a database.

If this is the case, on first page, you can collect nrocontacto as you have already done in your code and add a hidden input field <input type="hidden" name="nrocontacto" value="<?php echo $nrocontacto; ?>"> inside the form in the view file.

When the user submit the form, you can grab the value using $nroContacto = $this->input->post('NroContacto', true); (this code goes to form processing controller method). Now you can use CI query builder $this->db->insert('tableName', array('field_name' => $nroContacto)); (Note: add other required fields for insert array) to save it to the Database.



Answered By - mail2bapi
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing