Welcome Guest, Not a member yet? Register   Sign In
Post isn't returning anything.
#1

[eluser]lanzd[/eluser]
I don't know why my post isn't returning anything. I'm very new to codeigniter so I may be missing some crucial element. The initial problem is that my validation wasn't working. But, after looking at it I realized the code wasn't getting pas the if where it checks the value of the submit button. I have the method set to post on my form also. The name and values of my submit button also match up to the code in the controller. Here is my controller file

Code:
class Contact_us extends CI_Controller {

var $serverName = "";

var $departmentEmail = "[email protected]";
function __construct()
{
  parent::__construct();
  $this->serverName = "http://" . $_SERVER["SERVER_NAME"];
}


public function index()
{
  $data['test'] = $this->input->post();
  $data['serverName'] = $this->serverName;
  $data['deliveryStatus'] = "pending";
  $this->load->library('form_validation');
  
  
  if ($this->input->post('submit') == "Submit") {
   $this->form_validation->set_rules('name', 'Full Name', 'required');
   $this->form_validation->set_rules('email', 'Email', 'required');
   $this->form_validation->set_rules('comments', 'Comment/Details', 'required');
   if ($this->form_validation->run() == false) {
    foreach($this->input->post() as $fieldname => $fieldvalue) {
     $data[$fieldname] = $fieldvalue;
    }
    $this->load->view('templates/header',$data);
    $this->load->view('content/contact_us',$data);
    $this->load->view('templates/footer',$data);
    return;
   } else {
    // Let's try and email the message
    $message  = "message here";
    if (mail($this->departmentEmail, "Online inquiry from the www.somewebsite.com website", $message,"From: [email protected]")) {
     $data['deliveryStatus'] = "Message Sent.  A representative will contact you shortly.";
     //Let's clear the submission form
     foreach($this->input->post() as $fieldname => $fieldvalue) {
      $data[$fieldname] = "";
     }
    } else {
     $data['deliveryStatus'] = "We're Sorry.<br>It appears that we are experiencing technical difficulties.<br>Please try again later.";
    }
   }
  } else {
   $data['name'] = "";
   $data['email'] = "";
   $data['phone'] = "";
   $data['zipcode'] = "";
   $data['country'] = "";
   $data['company'] = "";
   $data['phone2'] = "";
   $data['comments'] = "";
  }
  
  $this->load->view('templates/header',$data);
  $this->load->view('content/contact_us',$data);
  $this->load->view('templates/footer',$data);
}
}

And I'm output the contents of the entire post variable 'test' with the line

Code:
<td>&lt;?php echo $test; ?&gt;<br /></td>


Thank you in advanced for any help.




Theme © iAndrew 2016 - Forum software by © MyBB