Booking and contact messqge
This commit is contained in:
+189
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class Home extends BaseController
|
||||
class Home extends basecontroller
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
@@ -43,17 +43,203 @@ class Home extends BaseController
|
||||
}
|
||||
public function contact(): string
|
||||
{
|
||||
return view('contact');
|
||||
|
||||
|
||||
|
||||
// $email = service('email');
|
||||
//
|
||||
//
|
||||
// $config['SMTPHost'] = 'smtp.googlemail.com';
|
||||
// $config['SMTPUser'] = 'support@chiefsoft.com';
|
||||
// $config['SMTPPass'] = 'may12002!';
|
||||
// $config['SMTPPort'] = '465';
|
||||
//
|
||||
// $config['SMTPCrypto'] = 'ssl';
|
||||
//
|
||||
// $config['protocol'] = 'sendmail';
|
||||
// $config['mailPath'] = '/usr/sbin/sendmail';
|
||||
// $config['charset'] = 'iso-8859-1';
|
||||
// $config['wordWrap'] = true;
|
||||
//
|
||||
// $email->initialize($config);
|
||||
//
|
||||
// $email->setFrom('support@gmail.com', 'ChiefsoftWorks Support');
|
||||
// $email->setTo('ses66181@gmail.com');
|
||||
////$email->setCC('another@another-example.com');
|
||||
////$email->setBCC('them@their-example.com');
|
||||
//
|
||||
// $email->setSubject('Email Test');
|
||||
// $email->setMessage('Testing the email class.');
|
||||
//
|
||||
// $email->send();
|
||||
|
||||
$data = [];
|
||||
if ($_POST){
|
||||
$message = $this->contactMessage();
|
||||
// echo "ameye 00 ......";
|
||||
$data['contact_sent'] = $this->pushEmail($message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return view('contact',$data);
|
||||
}
|
||||
private function bookMessage():string{
|
||||
$errorMSG = "";
|
||||
$fname = $lname = $email = $phone = $message = '';
|
||||
// FIRSTNAME
|
||||
if (empty($_POST["fname"])) {
|
||||
$errorMSG = "Full Name is required. ";
|
||||
} else {
|
||||
$fname = $_POST["fname"];
|
||||
}
|
||||
|
||||
// LASTNAME
|
||||
if (empty($_POST["lname"])) {
|
||||
$errorMSG = "Full Name is required. ";
|
||||
} else {
|
||||
$lname = $_POST["lname"];
|
||||
}
|
||||
|
||||
// EMAIL
|
||||
if (empty($_POST["email"])) {
|
||||
$errorMSG .= "Email is required. ";
|
||||
} else {
|
||||
$email = $_POST["email"];
|
||||
}
|
||||
|
||||
// PHONE
|
||||
if (empty($_POST["phone"])) {
|
||||
$errorMSG .= "Phone is required. ";
|
||||
} else {
|
||||
$phone = $_POST["phone"];
|
||||
}
|
||||
|
||||
// MESSAGE
|
||||
if (empty($_POST["message"])) {
|
||||
$errorMSG .= "Message is required. ";
|
||||
} else {
|
||||
$message = $_POST["message"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// prepare email body text
|
||||
$Body = "";
|
||||
$Body .= "Name: ";
|
||||
$Body .= $fname." ".$lname;
|
||||
$Body .= "\n";
|
||||
$Body .= "Email: ";
|
||||
$Body .= $email;
|
||||
$Body .= "\n";
|
||||
$Body .= "Phone: ";
|
||||
$Body .= $phone;
|
||||
$Body .= "\n";
|
||||
$Body .= "Message: ";
|
||||
$Body .= $message;
|
||||
$Body .= "\n";
|
||||
|
||||
|
||||
return $Body;
|
||||
}
|
||||
|
||||
private function contactMessage():string{
|
||||
$errorMSG = "";
|
||||
$fname = $lname = $email = $phone = $message = '';
|
||||
// FIRSTNAME
|
||||
if (empty($_POST["fname"])) {
|
||||
$errorMSG = "Full Name is required. ";
|
||||
} else {
|
||||
$fname = $_POST["fname"];
|
||||
}
|
||||
|
||||
// LASTNAME
|
||||
if (empty($_POST["lname"])) {
|
||||
$errorMSG = "Full Name is required. ";
|
||||
} else {
|
||||
$lname = $_POST["lname"];
|
||||
}
|
||||
|
||||
// EMAIL
|
||||
if (empty($_POST["email"])) {
|
||||
$errorMSG .= "Email is required. ";
|
||||
} else {
|
||||
$email = $_POST["email"];
|
||||
}
|
||||
|
||||
// PHONE
|
||||
if (empty($_POST["phone"])) {
|
||||
$errorMSG .= "Phone is required. ";
|
||||
} else {
|
||||
$phone = $_POST["phone"];
|
||||
}
|
||||
|
||||
// MESSAGE
|
||||
if (empty($_POST["message"])) {
|
||||
$errorMSG .= "Message is required. ";
|
||||
} else {
|
||||
$message = $_POST["message"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// prepare email body text
|
||||
$Body = "";
|
||||
$Body .= "Name: ";
|
||||
$Body .= $fname." ".$lname;
|
||||
$Body .= "\n";
|
||||
$Body .= "Email: ";
|
||||
$Body .= $email;
|
||||
$Body .= "\n";
|
||||
$Body .= "Phone: ";
|
||||
$Body .= $phone;
|
||||
$Body .= "\n";
|
||||
$Body .= "Message: ";
|
||||
$Body .= $message;
|
||||
$Body .= "\n";
|
||||
|
||||
|
||||
return $Body;
|
||||
}
|
||||
public function book(): string
|
||||
{
|
||||
return view('book');
|
||||
$data = [];
|
||||
if ($_POST){
|
||||
$message = $this->bookMessage();
|
||||
$data['contact_sent'] = $this->pushEmail($message);
|
||||
}
|
||||
return view('book',$data);
|
||||
}
|
||||
public function ourService(): string
|
||||
{
|
||||
return view('our-services');
|
||||
}
|
||||
|
||||
private function pushEmail($message) : string
|
||||
{
|
||||
$to = 'johnbullenterprises@gmail.com'; //'ses66181@gmail.com';//Type here the mail address where you want to send
|
||||
$subject = 'Subject of Email';//Write here Subject of Email
|
||||
//$message="Congrats ! You did it.";//Write the message you want to send
|
||||
//$email = \Config\Services::email();
|
||||
|
||||
$email = service('email');
|
||||
$email->setTo($to);
|
||||
$email->setFrom('support@chiefsoft.com', 'Contact Message');//set From
|
||||
$email->setSubject($subject);
|
||||
$email->setMessage($message);
|
||||
if($email->send())
|
||||
{
|
||||
$contact_sent = "Email has been Sent.";
|
||||
}
|
||||
else{
|
||||
$contact_sent= "Something went wrong !";
|
||||
$contact_sent ='';
|
||||
}
|
||||
/* */
|
||||
return $contact_sent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user