Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($hasForm){
- $template_header .= '
- <?php
- if(isset($_POST["check"])){
- '.$formInputsCode.'
- '.$formMessagesCode.'
- '.$formSettingsCode.'
- print \'<script "text/javascript">
- $(function() {\';
- $isset_errors = "";
- $hasEmail = false;
- $hasCaptcha = false;
- foreach($formInputs as $input){
- if(isset($_POST["form-field-" . $input]) && !empty($_POST["form-field-" . $input])){
- $isset_errors .= 0;
- print \'
- $("#form-field-"+"\'.$input.\'").val("\'.$_POST["form-field-" . $input].\'");
- \';
- // checking if the email fields exists
- if("form-field-" . $input == "form-field-email"){
- $hasEmail = true;
- }
- //checking if the captcha field exists
- if("form-field-" . $input == "form-field-captcha"){
- $hasCaptcha = true;
- }
- }
- else{
- $isset_errors .= 1;
- print \'
- $("#form-field-"+"\'.$input.\'").addClass("error");
- \';
- }
- }
- // Checking for errors
- if(is_int(strpos($isset_errors,"1"))){
- print \'
- $("#form-messages").html("<p class=\"text-danger\">\'.$formMessages[0].\'</p>")
- \';
- }
- else{
- $errors = "";
- if($hasEmail == true){
- $email = (string)$_POST["form-field-email"];
- if(preg_match(\'/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/\',$email)){
- $errors .= "0";
- }
- else{
- $errors .= "1";
- print \'
- $("#form-messages").append("<p class=\"text-danger\">\'.$formMessages[1].\'</p>")
- \';
- }
- }
- if($hasCaptcha == true){
- if($_SESSION["captcha"] == $_POST["form-field-captcha"]){
- $errors .= "0";
- }
- else{
- $errors .= "1";
- print \'
- $("#form-messages").append("<p class=\"text-danger\">\'.$formMessages[2].\'</p>")
- \';
- }
- }
- if(!is_int(strpos($errors,"1"))){
- print \'
- $("#form-messages").html("<p class=\"text-success\">\'.$formMessages[3].\'</p>")
- \';
- //
- // Iar aici trimitem mailul
- //
- if(isset($_POST["form-field-name"]) && !empty($_POST["form-field-name"]) ){
- $name = $_POST["form-field-name"];
- }
- else{
- $name = "(None)";
- }
- if(isset($_POST["form-field-email"]) && !empty($_POST["form-field-email"]) ){
- $mail = $_POST["form-field-email"];
- }
- else{
- $mail = "(None)";
- }
- if(isset($_POST["form-field-subject"]) && !empty($_POST["form-field-subject"]) ){
- $emailsubject = $_POST["form-field-subject"];
- }
- else{
- $emailsubject = "(None)";
- }
- $to = $formSettings[1];
- $subject = "['.$metaTitle.' Contact] ";
- $message = "Name: " . $name . "\r\n";
- $message .= "Email: " . $mail . "\r\n";
- $message .= "Subject: " . $emailsubject . "\r\n";
- $headers = "From: ".$formSettings[0];
- mail($to,$subject,$message,$headers);
- }
- }
- print \'});
- </script>\';
- }
- ?>
- ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement