<?php
$your_email = 'bestellungen@trumpettuning.eu'; 

session_start();
$errors = '';
$name = '';
$visitor_email = '';
$user_message = '';

if (isset($_POST['submit'])) {

    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $user_message = $_POST['message'];
    ///------------Do Validations-------------
    if (empty($name) || empty($visitor_email)) {
        $errors .= "\n Name and Email are required fields. ";
    }
    if (IsInjected($visitor_email)) {
        $errors .= "\n Bad email value!";
    }
    if (empty($_SESSION['6_letters_code']) ||
            strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) {
        //Note: the captcha code is compared case insensitively.
        //if you want case sensitive match, update the check above to
        // strcmp()
        $errors .= "\n The captcha code does not match!";
    }

    if (empty($errors)) {
        //send the email
        $to = $your_email;
        $subject = "Anfrage Walton Webseite";
        $from = $your_email;
        $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

        $body = "Ein Benutzer  $name hat das Kontaktformular ausgefuellt:\n" .
                "Name: $name\n" .
                "Email: $visitor_email \n" .
                "Message: \n " .
                "$user_message\n" .
                "IP: $ip\n";

        $headers = "From: $from \r\n";
        $headers .= "Reply-To: $visitor_email \r\n";

        mail($to, $subject, $body, $headers);

        header('Location: thank-you.html');
    }
}

// Function to validate against any email injection attempts
function IsInjected($str) {
    $injections = array('(\n+)',
        '(\r+)',
        '(\t+)',
        '(%0A+)',
        '(%0D+)',
        '(%08+)',
        '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if (preg_match($inject, $str)) {
        return true;
    } else {
        return false;
    }
}
?>
<!DOCTYPE html>

  <head>
   <link rel="stylesheet" href="/css/style.css" type="text/css">
        <script type="text/javascript" src="/js/jquery.js"></script>
        
       
        <script type="text/javascript" src="/js/waltonscripts.js"></script>
        <script type="text/javascript" src="/js/ktlang.js"></script>
<!--            <link href="http://fonts.googleapis.com/css?family=Petit+Formal+Script" rel="stylesheet" type="text/css">-->
<!--        <link href='http://fonts.googleapis.com/css?family=Trykker' rel='stylesheet' type='text/css'>-->
    <script>
    $(document).ready(function() {
  
      setLang(language);
    });
  </script>
  </head>
  
    
  <body >
            
        <div id="headline">
            <ul class="topbar">
                <li class="topbarli"><a onclick="changeLanguage('eng')"><img src="/images/English-Language-Flag-32.png"/></a></li>
                <li class="topbarli"><a onclick="changeLanguage('deu')"><img src="/images/Germany-Flag-32.png"/></a></li>
                
            </ul> 
        </div>
        <div id="navbardiv">
	        <nav >
            <ul class="navbar">
                <li class="navbarli" id="Home"><a href="/index.html">Home</a></li>
                <li class="navbarli" id="prof">
                    <a href="/products/walton_professional.html">Professional Line</a>
                    <ul id="profsub">
                        <li><a class="text_eng" href="/products/walton_prof_b.html">Bb-Trumpet</a><a class="text_deu" href="/products/walton_prof_b.html">B-Trompete</a></li>
                        <li><a class="text_eng" href="/products/walton_prof_c.html">C-Trumpet</a><a class="text_deu" href="/products/walton_prof_c.html">C-Trompete</a></li>
                        <li><a class="text_eng" href="/products/walton_prof_rotary.html">Rotary-Trumpet</a><a class="text_deu" href="/products/walton_prof_rotary.html">Drehventil Trompete</a></li>
                        <li><a  class="text_eng" href="/products/walton_prof_fgh.html">Flugelhorn</a><a class="text_deu" href="/products/walton_prof_fgh.html">Fl&uuml;gelhorn</a></li>
                        <li><a class="text_eng" href="/products/walton_prof_trb.html">Trombone</a><a class="text_deu" href="/products/walton_prof_trb.html">Posaune</a></li>
                        <li><a class="text_eng" href="/products/walton_prof_horn.html">French Horn</a><a class="text_deu" href="/products/walton_prof_horn.html">Doppelhorn</a></li>
                        <li><a class="text_eng" href="/products/walton_prof_euph.html">Euphonium</a><a class="text_deu" href="/products/walton_prof_euph.html">Euphonium</a></li>
                    </ul>
                </li>
                <li class="navbarli" id="student"><a href="#"></a>
                    <a href="/products/walton_student.html">Student Line</a>
                    <ul id="studsub">
                        <li><a class="text_eng" href="/products/walton_stud_trp.html" href="#">Bb-Trumpet</a><a class="text_deu" href="/products/walton_stud_trp.html">B-Trompete</a></li>
                        <li><a class="text_eng" href="/products/walton_stud_fgh.html">Flugelhorn</a><a class="text_deu" href="/products/walton_stud_fgh.html" >Fl&uuml;gelhorn</a></li>
                        <li><a class="text_eng" href="/products/walton_stud_cornet.html">Cornet</a><a class="text_deu" href="/products/walton_stud_cornet.html">Kornett</a></li>
                        <li><a class="text_eng" href="/products/walton_stud_euph.html">Euphonium</a><a class="text_deu" href="/products/walton_stud_euph.html">Euphonium</a></li>
                    
                    </ul>
                </li>
                </ul>
        	</nav>
          	<div class=".navseparator" id="navseparator3"></div>
       
            
        </div>
        <div id="centerwrapper">
        <div id="center">
	<p class="contact_eng">
		Any questions?<br>
Please do not hesitate to contact us</p>
	<p class="contact_deu">
		Fragen? Anregungen?<br>
		Wir freuen uns &uuml;ber Ihre Nachricht!
	</p>
         <div id='contact_form_errorloc' class='err'></div>
        <form method="POST" name="contact_form" 
              action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> 
            <p>
                <label for='name'>Name: </label><br>
                <input type="text" name="name" value='<?php echo htmlentities($name) ?>'>
            </p>
            <p>
                <label for='email'>Email: </label><br>
                <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'>
            </p>
            <p>
                <label for='message'>Message:</label> <br>
                <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea>
            </p>
            <p>
                <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
                <label for='message'>Enter the code above here :</label><br>
                <input id="6_letters_code" name="6_letters_code" type="text"><br>
                <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
            </p>
            <input type="submit" value="Submit" name='submit'>
        </form>

        <script language="JavaScript">
            // Code for validating the form
            // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
            // for details
            var frmvalidator  = new Validator("contact_form");
            //remove the following two lines if you like error message box popups
            frmvalidator.EnableOnPageErrorDisplaySingleBox();
            frmvalidator.EnableMsgsTogether();

            frmvalidator.addValidation("name","req","Please provide your name"); 
            frmvalidator.addValidation("email","req","Please provide your email"); 
            frmvalidator.addValidation("email","email","Please enter a valid email address"); 
        </script>
        <script language='JavaScript' type='text/javascript'>
            function refreshCaptcha()
            {
                var img = document.images['captchaimg'];
                img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
            }
        </script>
        
<!--        <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.de/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=Musik+Kr%C3%B6ger+Inh.+Franz-Josef+Kr%C3%B6ger+e.K.,+Saarstra%C3%9Fe,+Trier&amp;aq=0&amp;oq=musik+kr&amp;sll=49.777881,6.64946&amp;sspn=0.305504,0.891953&amp;ie=UTF8&amp;hq=musik+kr%C3%B6ger+inh+franz-josef+kr%C3%B6ger+ek&amp;hnear=Saarstra%C3%9Fe,+54290+Trier,+Rheinland-Pfalz&amp;t=m&amp;z=16&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.de/maps?f=q&amp;source=embed&amp;hl=de&amp;geocode=&amp;q=Musik+Kr%C3%B6ger+Inh.+Franz-Josef+Kr%C3%B6ger+e.K.,+Saarstra%C3%9Fe,+Trier&amp;aq=0&amp;oq=musik+kr&amp;sll=49.777881,6.64946&amp;sspn=0.305504,0.891953&amp;ie=UTF8&amp;hq=musik+kr%C3%B6ger+inh+franz-josef+kr%C3%B6ger+ek&amp;hnear=Saarstra%C3%9Fe,+54290+Trier,+Rheinland-Pfalz&amp;t=m&amp;z=16&amp;iwloc=A" style="color:#fff;text-align:left">Größere Kartenansicht</a></small>-->
            <p align="center"><b>Impressum:</b>Kr&ouml;ger Trumpets, Inh. Franz-Josef Kr&ouml;ger, Saarstr. 34, 54290 Trier, Germany</p>
            <p align="center">Phone: +49 651 49261, Fax: +49 651 49262, http://www.kroeger-trumpets.com</p>
            <p align="center">Umsatzsteuer-ID-Nummer: DE149828125, Handelsregister: Amtsgericht Wittlich (HRA 40096)</p>
        </div>
  </div>        
</div>
   <div class="abovefootbar">
            <img src="/images/KT_Walton_logo_thumb.png"/>
            <img src="/images/walton_straight_thumb.png"/>
            <a href="http://www.kroeger-trumpets.com"><img src="/images/KT_logo_thumb.png"/></a>
            <img src="/images/Laetzsch_BRASSWalton_thumb.png"/>
        </div>

        <div class="footbar">

        </div>


    </body>

</html>



