Skip to content

Commit

Permalink
send comment mail
Browse files Browse the repository at this point in the history
  • Loading branch information
Noushid committed Jul 6, 2017
1 parent 881e613 commit 2ab53e5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 8 deletions.
1 change: 1 addition & 0 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
$route['gst/(:num)'] = 'Home/blogView/$1';
$route['contact'] = 'Home/contact';
$route['send-message'] = 'Home/send_message';
$route['send-comment'] = 'Home/send_comment';
/*_______ public route End _______*/

/*_______ admin route start _______*/
Expand Down
34 changes: 34 additions & 0 deletions application/controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,39 @@ function send_message()
}
}

function send_comment()
{
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('phone', 'Email', 'required');

if ($this->form_validation->run() === FALSE) {
$this->output->set_status_header(400, 'Validation error');
} else {
$name = $this->input->post('name');
$phone = $this->input->post('phone');
$service = $this->input->post('service');

$service = wordwrap($service, 70, "<br>");
$subject = 'Comments from : ' . $name;

$message = 'name : ' . $name . PHP_EOL . PHP_EOL;
$message .= 'Request from : ' . $phone . PHP_EOL . PHP_EOL;
$message .= 'Requested Service : ' . $service . PHP_EOL . PHP_EOL;

$message = str_replace("\n.", "\n..", $message);

$to = '[email protected]';

$headers = 'From: [email protected]';

if (mail($to, $subject, $message, $headers)) {
$this->output->set_output('success');
} else {
$this->output->set_status_header(101, 'Mail server connect error');
$this->output->set_output('error');
}
}
}


}
20 changes: 13 additions & 7 deletions application/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
<div class="row">
<div class="col-md-12">
<div class="form-request">
<form action="#" method="post" id="commentform-footer" class="comment-form" novalidate="">
<form action="<?php echo base_url('send-comment')?>" method="post" id="commentform" class="comment-form">
<div class="post style-v1">
<div class="text-form">
<h2 class="title">Request Call Back.</h2>
Expand All @@ -329,8 +329,8 @@
</div>
<div class="post">
<div class="form-v1">
<select name="style cars">
<option value="1" selected="">How can we help?</option>
<select name="service">
<option value="" disabled selected="">How can we help?</option>
<option value="GST & IT CONSULTING">GST & IT CONSULTING</option>
<option value="ACCOUNTING & TAXATION">ACCOUNTING & TAXATION</option>
<option value="FORMATION SERVICES">FORMATION SERVICES</option>
Expand All @@ -339,17 +339,25 @@
<option value="TRAINING & PLACEMENT SERVICES">TRAINING & PLACEMENT SERVICES</option>
</select>
<fieldset class="style phone-container">
<input type="text" id="phone-footer" placeholder="Your Contact Number" class="tb-my-input" name="phone" tabindex="2" value="" size="32" aria-required="true">
<input type="text" id="phone-footer" placeholder="Your Contact Number" class="tb-my-input" name="phone" tabindex="2" value="" size="32" required="">
</fieldset>
</div>
</div>
<div class="post">
<div class="form-v2">
<fieldset class="style name-container">
<input type="text" id="author-footer" placeholder="You Name*" class="tb-my-input" name="author" tabindex="1" value="" size="32" aria-required="true">
<input type="text" placeholder="You Name*" class="tb-my-input" name="name" tabindex="1" value="" size="32" required="">
</fieldset>
<div class="submit-wrap">
<button class="flat-button button-style">submit <i class="fa fa-chevron-right"></i></button>
<div class="alert alert-success hide" id="comment-alert-success">
<i class="fa fa-check-circle-o fa-2x" aria-hidden="true"></i>
We will get you shortly! Thank you
</div>
<div class="alert alert-danger hide" id="comment-alert-error">
<i class="fa fa-times-circle-o fa-2x" aria-hidden="true"></i>
Sorry! Something went wrong
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -549,5 +557,3 @@
</div>
</section>
<!-- NEED HELP END -->


19 changes: 18 additions & 1 deletion public/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,21 @@
testimonial();
});

})(jQuery);
})(jQuery);

$('#commentform').submit(function (e) {
e.preventDefault();
$.post($(this).prop('action'),$(this).serialize())
.done(function(response) {
$('#commentform')[0].reset();
$('#comment-alert-success').removeClass('hide');
$("#comment-alert-success").delay(4).fadeIn();
$("#comment-alert-success").delay(4000).fadeOut();
})
.fail(function(response) {
$('#commentform')[0].reset();
$('#comment-alert-error').removeClass('hide');
$("#comment-alert-error").delay(4).fadeIn();
$("#comment-alert-error").delay(4000).fadeOut();
})
});

0 comments on commit 2ab53e5

Please sign in to comment.