<?php

// Uncomment the following two lines to troublshoot errors
//ini_set( 'display_errors', 1 );
//error_reporting( E_ALL );
	
if(isset($_POST['email'])) {
 
     
 
    // EDIT THE 2 LINES BELOW AS REQUIRED
 
    //$email_to = "WKFS-InfoDevSupport@wolterskluwer.com";
 
    //$email_subject = "Documentation Feedback";
 
     
 
     
 
    function died($error) {
 
        // your error code can go here
        
        echo "<span style='font-family: Segoe UI'>";
 
        echo "Sorry, but there were one or more errors found with the form you submitted.";
 
        echo "These errors appear below.<br /><br />";
 
        echo $error."<br /><br />";
 
        echo "Please <a href='#' onclick='history.go(-1)'>go back</a> and fix these errors.<br /><br />";
        
        echo "</span>";
 
        die();
 
    }
 
     
 
    // validation expected data exists
 
    if(!isset($_POST['full_name']) ||
 
        !isset($_POST['email']) ||
 
        !isset($_POST['telephone']) ||
 
        !isset($_POST['comments'])) {
 
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
 
    }
    
    // check value of Contact Me checkbox
    if (isset($_POST['ContactMe'])) {
        // Checkbox is selected
        $Contact = "Yes";
    } else {
       // Alternate code
       $Contact = "No";
    }
 
     
 
    $txtUrl = $_POST['txtUrl']; // not required
    $full_name = $_POST['full_name']; // required
    $company = $_POST['company']; // not required
    $email_from = $_POST['email']; // required
    $contact = $_POST['ContactMe']; // not required
    $telephone = $_POST['telephone']; // not required
    $product = $_POST['product']; // not required
    $comments = $_POST['comments']; // required
 
     

    $error_message = "";
 
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
 
  if(!preg_match($email_exp,$email_from)) {
 
    $error_message .= '<li>The Email Address you entered does not appear to be valid.</li><br />';
 
  }
 
    $string_exp = "/^[A-Za-z .'-]+$/";
 
  if(!preg_match($string_exp,$full_name)) {
 
    $error_message .= '<li>The Name you entered does not appear to be valid.</li><br />';
 
  }
 
  if(strlen($comments) < 2) {
 
    $error_message .= '<li>The Comments you entered do not appear to be valid.</li><br />';
 
  }
 
  if(strlen($error_message) > 0) {
 
    died($error_message);
 
  }
 
    //$email_message = "The following feedback was received using the Feedback form within the InfoDev online documentation.<br/><br/>" ;
 
     
 
    function clean_string($string) {
 
      $bad = array("content-type","bcc:","to:","cc:","href");
 
      return str_replace($bad,"",$string);
 
    }
    
    
    $myvardelete = substr($txtUrl, 0, (stripos($txtUrl, "=")+2));
    $txtUrl = str_replace($myvardelete, '', $txtUrl);
    //alert($txtUrl);
 
    $email_message .= '<html>
                        <head>
                          <style>
                            body{
	                            font-family:Segoe UI;
                            }
                            h1 {
                              font-size: 33px;
                              color: rgb(110, 187, 31);
                              font-weight: 100;
                              font-family: Segoe UI Light, Segoe UI, Helvetica, Garuda, Arial, sans-serif;
                              font-style: normal;
                              line-height: 1.167;
                            }
                            .bodytext {
                              font-family: Segoe UI, Helvetica, Garuda, Arial, sans-serif;
                              font-size: 14px;
                              font-style: normal;
                              font-variant: normal;
                              font-weight: normal;
                              line-height: 21px;
                            }
                            table {
	                            width:400px;
                              border:0;
                            }
                            tr.border_top td {
                              border-top:1pt solid black;
                            }
                            tr.border_bottom td {
                              border-bottom:1pt solid black;
                            }
                            td {
                              font-family: Segoe UI, Helvetica, Garuda, Arial, sans-serif;
                              font-size: 14px;
                              font-style: normal;
                              font-variant: normal;
                              font-weight: normal;
                              line-height: 21px;
                            }
                            .col1 {
                              font-weight: bold;
                              width: 150px;
                            }
                          </style>
                        </head>
                        <body>';
    $email_message .= "<h1>Online Documentation Feedback</h1>" ;
    $email_message .= "<p class='bodytext'>The following feedback was received using the Feedback form within the InfoDev online documentation.</p><hr/>" ;
    $email_message .= '<table cellpadding="4" width="100%"><col style="width:250"><col style="width:*">';
    
    $email_message .= "<tr>
                          <td class='col1'>Date and Time: </td>
                          <td>" . date('m/d/Y, H:i:s') . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Page URL: </td>
                          <td>" . strip_tags($_POST['txtUrl']) . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Name: </td>
                          <td>" . strip_tags($_POST['full_name']) . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Company: </td>
                          <td>" . strip_tags($_POST['company']) . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Email: </td>
                          <td>" . strip_tags($_POST['email']) . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Contact me? </td>
                          <td>" . $Contact . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Contact Number: </td>
                          <td>" . strip_tags($_POST['telephone']) . "</td>
                        </tr>";
    $email_message .= "<tr>
                          <td class='col1'>Product: </td>
                          <td>" . strip_tags($_POST['product']) . "</td>
                        </tr>";
    $email_message .= "<tr class='border_top border_bottom'>
                          <td class='col1'>Comment: </td>
                          <td>" . strip_tags($_POST['comments']) . "</td>
                        </tr>";
    $email_message .= "</table>";
    $email_message .= "</body></html>";
 


$email_to = "WKFS-InfoDevSupport@wolterskluwer.com";

// Subject
$subjectprepend = "Documentation feedback - ";
$email_subject = $subjectprepend . ' ' . $product;
     
 
// create email headers
 
$headers = 'From: '.$email_from."\r\n".
$headers .= 'Reply-To: '.$email_from."\r\n" .
$headers .= 'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
 
@mail($email_to, $email_subject, $email_message, $headers);  
 
?>
 
 
 
<!-- include your own success html here -->
 

<div style="font-family:'Segoe UI', 'Segoe UI Light', Helvetica, Garuda, Arial, sans-serif; margin:0 auto; margin-top:50px; width: 500px"> 
    <h2 style="color:rgb(110, 187, 31); font-family:'Segoe UI Light'">Thank you for contacting us.</h2>
    <p>We value our customers and your opinion.</p>
    <p>If you asked to be contacted regarding your submission, we will be in touch with you soon.</p>
    <p>Please close this window to return to your session.</p>
    
    <button type="button" 
            onclick="window.open('', '_self', ''); window.close();">Close</button>
 
</div>

 
<?php
 
}
 
?>