How does the controller know it was for it without passing the parameter in the 'echo open_form ()'?

0

I have a code here that I am studying as it does. See this view

insira o código aqui<div class="animate form login_form">
  <section class="login_content">

 <?php echo form_open('', 'id="form" name="form"'); ?>

 <h1>Login Administrativo</h1>
<div> <?php echo form_input(array('name' => 'usuario_usuario', 'type' => 'text', 'class' => 'form-control', 'id' => 'usuario_usuario',     'placeholder' => 'Digite um Usuário')); ?> </div>
<div> <?php echo form_input(array('name' => 'usuario_senha', 'type' => 'password', 'class' => 'form-control', 'id' => 'usuario_senha',   'placeholder' => 'Digite uma Senha')); ?> </div> 
<button type="submit" class="btn btn-default submit">Entrar </button>

<div class="clearfix"></div>

<div class="separator">
  <p class="change_link">Você quer criar uma conta?
 <?php echo anchor(base_url('admin#signup'), 'clique aqui!',    array('class' => 'to_register')); ?>
   </p>

  <div class="clearfix"></div><br />

  <div>
  <h4><i class=""></i> Luziânia Setor Leste GO</h4>
  <p>Igreja de Deus no Brasil em Luziânia</p>
  </div>

   </div>

 <?php echo form_close(); ?>

  </section>
  </div>

This view sends to the controller Login but I'm not understanding how it sends this form to the controller

    
asked by anonymous 08.09.2016 / 19:18

1 answer

1

When you do not put the address for page processing on the server, the code takes care of it and puts the page address in the code snippet just below it:

// If no action is provided then set to the current url
if ( ! $action)
{
    $action = $CI->config->site_url($CI->uri->uri_string());
}
// If an action is not a full URL then turn it into one
elseif (strpos($action, '://') === FALSE)
{
    $action = $CI->config->site_url($action);
}

Full Code:

function form_open($action = '', $attributes = array(), $hidden = array())
{
    $CI =& get_instance();

    // If no action is provided then set to the current url
    if ( ! $action)
    {
        $action = $CI->config->site_url($CI->uri->uri_string());
    }
    // If an action is not a full URL then turn it into one
    elseif (strpos($action, '://') === FALSE)
    {
        $action = $CI->config->site_url($action);
    }

    $attributes = _attributes_to_string($attributes);

    if (stripos($attributes, 'method=') === FALSE)
    {
        $attributes .= ' method="post"';
    }

    if (stripos($attributes, 'accept-charset=') === FALSE)
    {
        $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"';
    }

    $form = '<form action="'.$action.'"'.$attributes.">\n";

    // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
    if ($CI->config->item('csrf_protection') === TRUE && strpos($action, $CI->config->base_url()) !== FALSE && ! stripos($form, 'method="get"'))
    {
        $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
    }

    if (is_array($hidden))
    {
        foreach ($hidden as $name => $value)
        {
            $form .= '<input type="hidden" name="'.$name.'" value="'.html_escape($value).'" style="display:none;" />'."\n";
        }
    }

    return $form;
}
    
08.09.2016 / 21:59