Contact Us
If you need moodle theme customization based on our free template or any feedbacks, please leave a message here.
// Contact form class to validate the mandatory fiends and send mail // please change recipient address in line 128 and from address in line 132 and then use this contact form. class Contactform { // function validate to validate the required fields which is indicated by * function validate() { $errmsg=""; // initialize the errmsg to zero; $newline=""; if(!$this->validatename($_POST['name'])) // validate the name field , this function calls the validatename function { $errmsg.="Please Tell US Your Name: "."$newline"; } if(!$this->validateemail($_POST['email'])) // validate the email field { $errmsg.="Please Tell Us Your Email: "."$newline"; } /* if(!$this->validatephone($_POST['phone'])) // validate the phone field { $errmsg.="Please Enter Your Telephpone Number"."$newline"; } */ if(!$this->validatemessage($_POST['message'])) // validate the message { $errmsg.="Please Write Your Message: "."$newline"; } return $errmsg; // return error message if any mistake in filling the form else it return null } function validatename($name) // this function to validate name { //if(eregi("^[a-zA-Z0-9]+$","$name")) //if(isset($_POST['name']) if($name) { return 1; } else { return 0; } } function validateemail($email) // this function to validate email { if(eregi("^[a-z0-9_.]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$","$email")) { return 1; } else { return 0; } } /* function validatephone($phone) // this function to validate phone { if(eregi("^[+0-9]+$","$phone")) { return 1; } else { return 0; } } */ function validatemessage($message) // this function to validate message { if($message) { return 1; } else { return 0; } } function mailsend() // this function to send mail if the validation true { $msg = "Name\n $_POST[name]"; // assign all the post data fields to the variable $msg .= "\n\nEmail\n $_POST[email]"; //$msg .= "\n\nTelephone\n $_POST[phone]"; //$msg .= "\n\nMobile\n $_POST[mobile]"; //$msg .= "\n\nCountry\n $_POST[country]"; //$msg .= "\n\nCompany\n $_POST[company]"; $msg .= "\n\nMessage\n $_POST[message]"; //Setup the mail format $recipient = "charlesdao99@gmail.com"; // Recipient mail address $subject = "From 99template"; // subject of the mail $mailheaders = "MIME-Version: 1.0\r\n"; $mailheaders .= "Content-type: text/plain; charset=utf-8\r\n"; $mailheaders .= "From:contact@99cfa.com \r\n"; // from address fo the person $mailheaders .= "Reply-To: $_POST[email]\r\n"; // reply field //Send the contact form $sent=mail($recipient, $subject, $msg,$mailheaders); // this function to send mail to the recpient if($sent) { $rs="We have Received Your Message and Will Contact You As Soon As Possible "; // display this message if the message sent successfully return $rs; } else { $rs="Sorry, Some problem in server please try again later"; // display the error message if the message not sent return $rs; } } }; $name=$_POST['name']; //$phone=$_POST['phone']; $message=$_POST['message']; $email=$_POST['email']; //$mobile=$_POST['mobile']; //$country=$_POST['country']; //$company=$_POST['company']; $obj=new Contactform(); //create object to the Contactform class if($_POST['submit']) // if the user click the submit button this loop will execute { $rs=$obj->validate(); // call the validate function using the object if($rs=="") { $confirm=$obj->mailsend(); // if the validation succeed, call the sendmail() function echo "