Welcome Guest, Not a member yet? Register   Sign In
URL shows non view function
#1

[eluser]Gukkie[/eluser]
Hi, i have a little problem here. Why is it when i click submit on a form and it there is an error, i get redirected to the url doing the function of the submit button instead of the view url?

eg.
Code:
function resend_activation($message = '')
{
  $data['title']        = 'My Site | Resend Activation Email';
  $data['description']  = '';
  $data['keywords']     = '';
  $data['robot']        = 'NOINDEX, NOFOLLOW';
  
  $data['message']      = $message ;
  $data['main_content'] = 'user/resend_activation';

  $this->load->view('includes/template', $data);
}
Now, the function that controls the form submission:
Code:
function do_resend()
{
  if($this->input->post('submit'))
  {
    $this->form_validation->set_rules('email', '<b>Email Address</b>', 'trim|required|valid_email|callback_validate_email');
  
   $this->form_validation->set_error_delimiters('<div class="input_error">', '</div>');
  
   if($this->form_validation->run() == FALSE)
   {
    $this->resend_activation('Please correct the errors in the form.');
   }
   else
   {
    $email = $this->input->post('email');
    $this->resend_activation('Activation email successfully sent. Please check your email.');
   }
  }
}

View:
Code:
&lt;?=(isset($message) && $message) ? $this->load->view('includes/message') : '';?&gt;
&lt;?=form_open('user/do_resend');?&gt;
<dl>
   &lt;?=form_error('email');?&gt;
   <dt>&lt;?=form_label('Email Address :');?&gt;</dt>
   <dd>&lt;?=form_input('email', $this->input->post('email'), 'size=25, maxlength=64');?&gt;</dd>
              
   <dt></dt>
   <dd>&lt;?=form_submit('submit', 'Submit');?&gt;</dd>
</dl>
&lt;?=form_close();?&gt;

Now, the url for the resend email page would be "http://www.domain.com/user/resend_activation",
but when i click submit, why does the url change to "http://www.domain.com/user/do_resend" ?

Any way i can fix this instead of using redirect(), as redirect does not pass my variable message into the view?




Theme © iAndrew 2016 - Forum software by © MyBB