• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get method doesn't work properly

#1
[eluser]mazzy[/eluser]
this is my code in the view:


Code:
<form action="<?php echo site_url("search/send_mail?uid=$id"); ?>" method="post" accept-charset="utf-8" data-ajax="false">
                    <div class= "ui-hide-label">
                        <label for="email">Email</label>
                        &lt;input type="email" name="email" id="email" placeholder="Email"/&gt;
                    </div>
                    </br>
                    &lt;input type="submit" id="submit" value="Send info to mail" data-theme="b"/&gt;
                &lt;/form&gt;


and this is the function in my controller `search`:



Code:
function send_mail()
        {
            
                $config['protocol'] = 'smtp';
                $config['smtp_host'] = 'ssl://smtp.googlemail.com';
                $config['smtp_port'] = '465';
                $config['smtp_user'] = '[email protected]';
                $config['smtp_pass'] = '***********';
                $config['mailtype'] = 'html';
                $config['newline'] = "\r\n";
                $this->email->initialize($config);
    
                $this->email->from('mymail','User');
                $mail = $this->input->post('email');
                $this->email->to($mail);
                
                $id = $this->input->get('id');
                                            
                var_dump($id); die(); /* empty value */
                
                $this->email->subject('User Medical Info');
                $this->email->message();
    
                $data['title'] = 'Send mail';
                $data['result'] = $this->email->send();
    
                $this->load->view('templates/_header',$data);
                $this->load->view('_result_mail',$data);  
            
        }


I pass the value $id through get in the view but for a strange reason the get in controller give me a false as result. there is maybe a conflict between post and get?

#2
[eluser]CroNiX[/eluser]
Why not just send $id as the 3rd parameter in your form action and then grab it from the uri:Confusedegment(3)?

search/send_mail/$id
Code:
function send_mail()
{
  $id = $this->uri->segment(3);
  if ($id !== FALSE)
  {
    //...
  }
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.