public function complaint_enquiry_submit() { /* |-------------------------------------------------------------------------- | Allow POST Requests Only |-------------------------------------------------------------------------- */ if (empty($_POST)) { redirect('complaint-enquiry'); return; } /* |-------------------------------------------------------------------------- | Spam Honeypot Protection |-------------------------------------------------------------------------- */ $honeypot = trim( (string) $this->input->post('website', true) ); if ($honeypot !== '') { log_message( 'error', 'Complaint form spam blocked from IP: ' . $this->input->ip_address() ); redirect('complaint-enquiry'); return; } /* |-------------------------------------------------------------------------- | Prevent Repeated Submissions Within 30 Seconds |-------------------------------------------------------------------------- */ $lastSubmission = (int) $this->session->userdata( 'last_public_form_submission' ); if ( $lastSubmission > 0 && (time() - $lastSubmission) < 30 ) { $this->session->set_userdata([ 'public_form_class' => 'danger', 'public_form_message' => 'Please wait 30 seconds before submitting another request.' ]); redirect('complaint-enquiry'); return; } /* |-------------------------------------------------------------------------- | Form Validation Rules |-------------------------------------------------------------------------- */ $this->form_validation->set_rules( 'name', 'Full Name', 'trim|required|max_length[100]' ); $this->form_validation->set_rules( 'mobile', 'Mobile Number', 'trim|required|regex_match[/^[0-9]{10}$/]' ); $this->form_validation->set_rules( 'email', 'Email Address', 'trim|valid_email|max_length[150]' ); $this->form_validation->set_rules( 'customer_id', 'Customer ID / Connection Number', 'trim|max_length[100]' ); $this->form_validation->set_rules( 'type', 'Complaint / Enquiry Type', 'trim|required|in_list[Complaint,Service Request,Enquiry,New Connection,Other]' ); $this->form_validation->set_rules( 'subject', 'Subject', 'trim|required|max_length[200]' ); $this->form_validation->set_rules( 'message', 'Message', 'trim|required|max_length[2000]' ); /* |-------------------------------------------------------------------------- | Display Validation Errors |-------------------------------------------------------------------------- */ if (!$this->form_validation->run()) { $this->setSeo( 'Complaint / Enquiry | iGateways', 'Submit your complaint, service request or enquiry to iGateways.', 'complaint-enquiry', 'iGateways complaint, broadband enquiry, internet complaint' ); $this->loadTemplate( 'complaint-enquiry', $this->data ); return; } /* |-------------------------------------------------------------------------- | Sanitized Form Values |-------------------------------------------------------------------------- */ $name = $this->input->post( 'name', true ); $mobile = $this->input->post( 'mobile', true ); $email = $this->input->post( 'email', true ); $customerId = $this->input->post( 'customer_id', true ); $type = $this->input->post( 'type', true ); $subject = $this->input->post( 'subject', true ); $message = $this->input->post( 'message', true ); /* |-------------------------------------------------------------------------- | Prepare Database Message |-------------------------------------------------------------------------- */ $completeMessage = "Type: " . $type . "\n" . "Customer ID / Connection No.: " . ( !empty($customerId) ? $customerId : 'Not provided' ) . "\n" . "Subject: " . $subject . "\n\n" . "Message:\n" . $message; $queryData = [ 'name' => $name, 'number' => $mobile, 'email' => $email, 'message' => $completeMessage ]; /* |-------------------------------------------------------------------------- | Save in Database |-------------------------------------------------------------------------- */ $this->adminModel->createQuery( $queryData ); /* |-------------------------------------------------------------------------- | Store Successful Submission Time |-------------------------------------------------------------------------- */ $this->session->set_userdata( 'last_public_form_submission', time() ); /* |-------------------------------------------------------------------------- | Prepare Support Email |-------------------------------------------------------------------------- */ $emailBody = "
Name: " . htmlspecialchars( $name, ENT_QUOTES, 'UTF-8' ) . "
Mobile: " . htmlspecialchars( $mobile, ENT_QUOTES, 'UTF-8' ) . "
Email: " . htmlspecialchars( !empty($email) ? $email : 'Not provided', ENT_QUOTES, 'UTF-8' ) . "
Type: " . htmlspecialchars( $type, ENT_QUOTES, 'UTF-8' ) . "
Customer ID: " . htmlspecialchars( !empty($customerId) ? $customerId : 'Not provided', ENT_QUOTES, 'UTF-8' ) . "
Subject: " . htmlspecialchars( $subject, ENT_QUOTES, 'UTF-8' ) . "
Message:
" .
nl2br(
htmlspecialchars(
$message,
ENT_QUOTES,
'UTF-8'
)
) .
"
The page you requested was not found.