Trouble returning to page after form submission - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Trouble returning to page after form submission (/showthread.php?tid=58309) Pages:
1
2
|
Trouble returning to page after form submission - El Forum - 06-02-2013 [eluser]Tekamba[/eluser] OK, my previous attampt at a fix, while it works, doesn't make passing the form values BACK to the form very easy. Because I have to pass everything to a separate file which then re-directs to my form page, I lose the POST data stored. From what I am seeing there are 2 (probably more, but 2 I can think of) ways to handle this: 1) Figure out WHAT is adding the .php to my call BACK to the form page. The link is correct, if it didn't have the .php, I don't have that in code, so has to be something else adding it. I am just not sure what. 2) Pass all the form values (one of the forms on this site is an applcation that will take a LOT of storage, but they don't want to keep all that data so it seems silly to store it in a database, rather we are just sending it along in an email. So is there a simple way to pass ALL active variables into a flashdata array? Or something similar? Hoping someone has a suggestion, for 2 of the 3 forms manually storing the form data into flashdata values won't be too cumbersome as there are a total of probably 10-15 fields between the forms. The employment application form is another matter, however. And I definitely don't want them to have their users needing to retype all their data. Greg Trouble returning to page after form submission - El Forum - 06-02-2013 [eluser]Tekamba[/eluser] Here is the code from my form handling controller. I have a feeling I have something in here that I have not done correctly and that may be causing the issue, this is all held in a class called email. "Main" is the website controller, and "contact" is the webpage where the contact form resides. The email is sent when form validation completes, the only error I have is when the function callcontact() call is made (even if I do it without the separate function I still end up with the error that main/contact.php can't be located. function callcontact() { $this->load->view('main/contact'); } function contact_send() { /*******************************************/ /* A contact form was submitted */ /*******************************************/ // load the form validation library $this->load->library('form_validation'); // setup validation rules on form fields $this->form_validation->set_rules('name', 'Name', 'trim|required'); $this->form_validation->set_rules('phone', 'Phone', 'trim|required'); $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email'); $this->form_validation->set_rules('reason', 'Reason for contact request', 'trim|required|'); // run form validation if($this->form_validation->run() == FALSE) { // form failed to validate so pass the errors to flashdata // and then return user to form $this->session->set_flashdata('errors', validation_errors()); $this->callcontact(); } else { // validator has passed - compile the email $messagebody = "Name: "; $messagebody .= $name = $this->input->post('name'); $messagebody .= "<br>Phone: "; $messagebody .= $email = $this->input->post('phone'); $messagebody .= "<br>E-Mail: "; $messagebody .= $email = $this->input->post('email'); $messagebody .= "<br>Reason: "; $messagebody .= $email = $this->input->post('reason'); $msg_subject = 'Contact Form Request'; $msg_valid_send = 'Thank you for your contact request'; $msg_error_send = 'Contact form message did not process properly'; } /********************************************/ /* Validation&Message; construction are done */ /* send the message to Staff */ /********************************************/ // create array to store smtp values $config = Array( 'protocol' => $this->config->item('smtp_protocol'), 'smtp_host' => $this->config->item('smtp_host'), 'smtp_port' => $this->config->item('smtp_port'), 'smtp_user' => $this->config->item('smtp_user'), 'smtp_pass' => $this->config->item('smtp_pass'), 'mailtype' => $this->config->item('smtp_mailtype'), 'charset' => $this->config->item('smtp_charset'), 'recipient' => $this->config->item('smtp_recipient')); // load the email library class $this->load->library('email', $config); $this->email->set_newline("\r\n"); // set to, from, message, etc $this->email->from($this->input->post('email')); $this->email->to($config['recipient']); $this->email->subject($msg_subject); $this->email->message($messagebody); // attempt to send the email if ($result = $this->email->send()) { $message = $msg_valid_send; } else { $message = $msg_error_send; } $this->session->set_flashdata('messagestatus', $message); // send user back to the appropriate form $this->callcontact(); //$this->load->view('send_contact'); } |