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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:17:33+00:00 2026-05-30T16:17:33+00:00

I have this situation. For example, Path: localhost/intranet/ If i enter this url: localhost/intranet/usuarios/actualizar/richard

  • 0

I have this situation. For example,

Path: localhost/intranet/

If i enter this url:

localhost/intranet/usuarios/actualizar/richard

and leave all fields blank and send submit, the validation runs fine and show me the error: “all those fields are required”. But, if i click send again, it will send me to:

localhost/intranet/usuarios/actualizar/

Hint: usuarios = USERS in english, actualizar = UPDATE_INFO.

So, as you can see, the argument, in this case richard is mising. Im running 2.1 CodeIgniter. Why is this happening? i don’t want CodeIgniter miss the argument because it will show many errors related to CI not being able to find a argument to work with.

Is this normal? Can anyone can click two times when validation fails to see if is the same behavior?

UPDATE #1 Added method for update the data

public function actualizar() {

        // we check if the form was submited. If not, load register view.
        if($_SERVER['REQUEST_METHOD'] == "POST") {

        // translation for errors.
        $required_msg = "<strong>%s</strong> es un campo obligatorio.";
        $exact_length_msg = "<strong>%s</strong> debe contener 10 dígitos exactamente.";
        $numeric_msg = "<strong>%s</strong> debe contener solamente dígitos.";
        $email_msg = "<strong>%s</strong> debe ser una dirección válida.";
        $unique_msg = "<strong>%s</strong> ya está registrado en el sistema. Seleccione uno distinto.";


        // set the messages with translations.
        $this->form_validation->set_message('required', $required_msg);
        $this->form_validation->set_message('exact_length', $exact_length_msg);
        $this->form_validation->set_message('numeric', $numeric_msg);
        $this->form_validation->set_message('valid_email', $email_msg);
        $this->form_validation->set_message('is_unique', $unique_msg);

        // set the rules for each input field           
        $this->form_validation->set_rules('userName', 'Nombre', 'trim|required');
        $this->form_validation->set_rules('userLastName', 'Apellido', 'trim|required');
        $this->form_validation->set_rules('userUsername', 'Nombre de Usuario', 'trim|required|is_unique[usuarios.userUsername]');
        $this->form_validation->set_rules('userCellphone', 'Teléfono', 'trim|numeric|exact_length[10]');
        $this->form_validation->set_rules('userEmail', 'Correo Electrónico', 'trim|required|valid_email||is_unique[usuarios.userEmail]');
        $this->form_validation->set_rules('userAddress', 'Dirección', 'trim|required');

        // set the custom delimiters for each error msg
        $this->form_validation->set_error_delimiters('<li>', '</li>');

            // we check if the validation pass the rules. If not, show the view again with errors msgs.
            if($this->form_validation->run() == FALSE) {
                $data['title'] = "Registrar Usuario";
                $data['page_title'] = "Panel de Control";
                $data['header']  = "header";
                $data['scripts'] = array('alert-dismiss');
                $data['body']    = "usuarios-actualizar";
                $this->load->view('template', $data);
            } else {

                // if validation went ok, we capture the form data.
                $fields = array(
                    'userName' => $this->input->post('userName'),
                    'userLastName' => $this->input->post('userLastName'),
                    'userUsername' => $this->input->post('userUsername'),
                    'userEmail' => $this->input->post('userEmail'),
                    'userAddress' => $this->input->post('userAddress'),
                    'userCellphone' => $this->input->post('userCellphone'),
                    'userIn' => $this->input->post('userIn'),
                    'userOut' => $this->input->post('userOut'),
                    'userLastLogin' => '',
                    'userRole' => $this->input->post('userRole')
                 );

                 $userName = $this->input->post('userName');
                 $userLastName = $this->input->post('userLastName');
                 $userEmail = $this->input->post('userEmail');
                 $userID = $this->input->post('userID');
                 $userUsername = $this->input->post('userUsername');

                // send the $data to the model                          
                if($this->Data_model->update_entry($userID, $fields) == TRUE) {
                    $this->session->set_flashdata('alert', 'El perfil ha sido actualizado con éxito.');
                    $this->session->set_flashdata('style', 'success');
                    redirect('usuarios/perfil/' . $userUsername);
                } else {
                    $this->session->set_flashdata('alert', 'Hubo un error actualizando el perfil. Inténtelo de nuevo.');
                    $this->session->set_flashdata('style', 'error');
                    redirect('usuarios/perfil/' . $userUsername);
                }

            }

        // If the request method is not POST, it means that form was not submitted.
        } else {
            $data['title'] = "Actualizar Datos";
            $data['page_title'] = "Actualizar Datos";
            $data['header']  = "header";
            $data['scripts'] = array('alert-dismiss');
            $data['body']    = "usuarios-actualizar";
            $data['user'] = $this->Data_model->get_profile_for_update($userUsername);
            $this->load->view('template', $data);
        }
    }
<?=form_close?>

I just told CI load the view, not redirect and lose the url. I repit: first time, it works cool. But if i don’t change anything and just press SEND again, it fails 🙁 Just noticed that tonight. Just by curiosity pressed send again and it went to hell.

Hope someone can give me some idea of whats going on. Thanks.

P.S. Maybe this guy has the same problem. Not quite sure…
CodeIgniter Set Form Validation Redirect URL

UPDATE #2 Added view code

     <?=form_open('usuarios/actualizar')?> 

  <?php
      $config = array(
        'type' => 'submit',
        'content' => '<i class="icon-ok icon-white"></i> Guardar Usuario',
        'class' => 'btn btn-primary'
      );
  ?>

  <div class="row">
      <h2 class="section-title span10">Actualizar Usuario</h2>
    <div class="span2">
      <?=form_button($config)?>
    </div>  
  </div>

  <?php if (validation_errors() != null) : ?>
  <div class="alert alert-warning fade in">
  <a class="close" data-dismiss="alert">&times;</a>
    <ul class="unstyled">
      <?=validation_errors()?>
    </ul>
  </div>
  <?php endif;?>

    <div class="span5">  
      <h3 class="box-title">Datos Personales</h3>
        <input type="hidden" name="userID" value="<?=$user->userID ?>">
        <label>Nombre<span class="required">*</span></label>
        <input type="text" class="span4" name="userName" value="<?=set_value('username', $user->userName)?>">
        <label>Apellido<span class="required">*</span></label>
        <input type="text" class="span4" name="userLastName" value="<?=set_value('userLastName', $user->userLastName)?>">
        <label>Teléfono</label>
        <input type="text" class="span4" name="userCellphone" value="<?=set_value('userCellphone', $user->userCellphone)?>">
        <label>Correo Electrónico<span class="required">*</span></label>
        <input type="text" class="span4" name="userEmail" value="<?=set_value('userEmail', $user->userEmail)?>">
        <label>Dirección<span class="required">*</span></label>
        <textarea class="span4" name="userAddress"><?=set_value('userAddress', $user->userAddress)?></textarea>
    </div>

It doesnt work because it can’t find the argument so the $user object can’t be created.
That lead like a ton of errors.

SOLUTION:

I don’t have so much rep so i can’t answers myself but here is the solution:

Oh my god. Maybe im falling asleep.

As Madmartigan states, i wasn’t using the “argument”. So, i added this:

$data['user'] = $this->Data_model->get_profile_for_update($this->uri->segment(3));

Sooo, i doesn’t matter if it “lose” the argument in the URL, it works because before it loads the view, call the $data[‘user’] stuff 🙂

Thank you for your help guys, you are the best.

  • 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-30T16:17:34+00:00Added an answer on May 30, 2026 at 4:17 pm

    It seems pretty obvious:

    <?=form_open('usuarios/actualizar')?>
    

    This will always post to usuarios/actualizar, so you would lose any other URI segments or query string. Just leave it blank to post to the current url:

    <?=form_open()?>
    

    …although, I don’t see that actualizar() actually does anything with the arguments passed to it in the url, so it’s not clear why you want it to be usuarios/actualizar/richard, as richard doesn’t appear to be used.

    EDIT: OK, now I see it: $this->uri->segment(3). You need to be able to handle the case of this not being set, so in addition do this in your controller to prevent errors:

    $userUsername = $this->uri->segment(3);
    if ( ! $userUsername) show_404();
    

    Just for the record, you can also do this to set a default “username”:

    public function actualizar($userUsername = 'Default Name') {
        // your code
    }
    

    Because CI is pretty strict about what it allows in the URL, you might be better off using the query string instead for names if you expect characters that aren’t allowed in your $config['permitted_uri_chars'].

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

Sidebar

Related Questions

I have this example here to illustrate the situation: http://jsfiddle.net/nubrF/40/ If you hold your
I have this situation: $(#button).toggle(function(){ $(#window).animate({top:'0%'},1000); },function(){ $(#window).animate({top:'-100%'},1000); }); but I need change it
I have this situation: http://jsfiddle.net/bRDgK/3/ In this situation I have a modal dialog with
I have this situation: { float foo[10]; for (int i = 0; i <
I have this situation where I want to display a list of Administration objects
We have this situation: Window Keyboard ^ ^ | / ApplicationWindow so class Window
I have this situation: interface MessageListener { void onMessageReceipt(Message message); } class MessageReceiver {
I have this situation: There are a login page with a login form (form
I have this situation where i have to start an activity from my mainActivity.
I have this situation: web application with cca 200 concurent requests (Threads) are in

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.