0

I'm trying to make a basic reservation system. When the reservation is made via the .html document, it should send a mail to my email address. But this is not the case.

I searched for mailing with Xampp via localhost and found a bunch of posts of changing the php.ini and sendmail.ini files, changing the smtp settings to gmail.

But I'm not able to make it work. I'm I doing something wrong or overlooking/forgetting something? Is there another way to test out my code if it works then trying it out with Xampp?

If needed I can post my php.ini and sendmail.ini files.

PHP code

<?php

    $message = "";

    //email adres
    $email = "tom.deboeck23@gmail.com";

    $required = array('dag', 'maand', 'jaar', 'uur', 'minuten', 'naam','email', 'telefoon', 'aantal', 'bericht', 'type');

    if (isset($_POST['reserveren']))
    {
        $data = $_POST['reservatie'];

        $headers = "";

        $message .= "Dag Lode en Eva, via de website kregen jullie een nieuwe reservatie, gelieve de persoon zo snel mogelijk een bevestigingsmail te sturen!";
        $message .= "\n\n";
        $message .= $data['bericht'];
        $message .= "\n\n";

        $message .= "Telefoon: " . $data['telefoon'];
        $message .= "\n\n";
        $message .= "Lunch/Diner: " . $data['type'];
        $message .= "\n\n"; 
        $message .= "Aantal personen: " . $data['aantal'];
        $message .= "\n\n";
        $message .= "Email: " . $data['email'];
        $message .= "\n\n";

        $message .= "Datum: " . $data['dag'];
        $message .= "\n\n";
        $message .= "Maand: " . $data['maand'];
        $message .= " " . $data['jaar'];
        $message .= "\n\n";
        $message .= " Tijdstip: " . $data['uur'] . " " . $data['minuten'];

        $subject = 'Nieuwe reservatie via de website';
        $headers = 'From: '. $data['email']. "\r\n" .'Reply-To: '. $data['email']. "\r\n" .'X-Mailer: PHP/' . phpversion();

        if (mail($email, $subject, $message, $headers))
        {
           echo "mail verstuurd!";
        }           
    }    
?>

HTML code

<!DOCTYPE html>
<html>

    <head>
        <meta charset ="UTF-8">
        <title>Baronie - Reservatie</title>

    </head>
    <body>

        <form action='reservatie.php' method="post">

            <h4>Gewenste datum</h4>

                <select id="dag" name="reservatie[dag]">
                    <option value="01">01</option>
                    <option value="02">02</option>
                    <option value="03">03</option>
                    <option value="04">04</option>
                    <option value="05">05</option>
                    <option value="06">06</option>
                    <option value="07">07</option>
                    <option value="08">08</option>
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                    <option value="24">24</option>
                    <option value="25">25</option>
                    <option value="26">26</option>
                    <option value="27">27</option>
                    <option value="28">28</option>
                    <option value="29">29</option>
                    <option value="30">30</option>
                </select>

                <select id="maand" name="reservatie[maand]">
                    <option value="Januari">Januari</option>
                    <option value="Februari">Februari</option>
                    <option value="Maart">Maart</option>
                    <option value="April">April</option>
                    <option value="Mei">Mei</option>
                    <option value="Juni">Juni</option>
                    <option value="Juli">Juli</option>
                    <option value="Augustus">Augustus</option>
                    <option value="September">September</option>
                    <option value="Oktober">Oktober</option>
                    <option value="November">November</option>
                    <option value="December">December</option>
                </select>   

                <select id="jaar" name="reservatie[jaar]">
                    <option value="2015">2015</option>
                    <option value="2016">2016</option>
                </select>   

            <h4>Gewenste tijdstip</h4>

                <select id="uur" name="reservatie[uur]">
                    <option value="12">12u</option>
                    <option value="13">13u</option>
                    <option value="14">14u</option>             
                    <option value="18">18u</option>
                    <option value="19">19u</option>
                    <option value="20">20u</option>
                    <option value="21">21u</option>                 
                </select>

                <select id="minuten" name="reservatie[minuten]">
                    <option value="00">00 min</option>
                    <option value="05">05 min</option>
                    <option value="10">10 min </option>
                    <option value="15">15 min</option>
                    <option value="20">20 min </option>
                    <option value="25">25 min </option>
                    <option value="30">30 min </option>
                    <option value="35">35 min </option>
                    <option value="40">40 min </option>
                    <option value="45">45 min</option>
                    <option value="50">50 min </option>
                    <option value="55">55 min</option>
                </select>

            <h4>Reservatie</h4>

                <select id="type" name="reservatie[type]">
                    <option value="Diner">Diner</option>
                    <option value="Middaglunch">Lunch</option>
                </select><br><br>

                <input type="text" id="aantal" placeholder="Aantal personen" name="reservatie[aantal]"><br><br>

                <input type="text" id="naam" placeholder="Naam" name="reservatie[naam]"><br><br>

                <input type="text" id="email" placeholder="Email" name="reservatie[email]"><br><br>

                <input type="tel" id="telefoon" placeholder="Telefoon" name="reservatie[telefoon]"><br><br>

                <textarea id="bericht" placeholder="Bericht" name="reservatie[bericht]"></textarea><br><br><br>

                <input type="submit" name="reserveren" value="Reserveren">
        </form>

    </body> 
</html>
halfer
  • 19,824
  • 17
  • 99
  • 186
user3360972
  • 107
  • 2
  • 13
  • Did you set up tomcat? – Toza Sep 17 '15 at 06:45
  • Have you turned on error reporting? If not, place this at the top of your php file: `error_reporting(E_ALL); ini_set("display_errors", 1);` – Epodax Sep 17 '15 at 06:47
  • That code is irrelevant. This isn't a programming question, but about ›server‹ configuration (thus off-topic). – mario Sep 17 '15 at 06:57
  • D:\Apps\Xampp\mailoutput <= this is actually a step in the right direction. Here I can see the mails that are being sent atleast as a textfile. Would just like it if it would work in a real environment. – user3360972 Sep 17 '15 at 07:01
  • @mario - instead of making a comment that doesn't help, make one then that will point me in the right direction.. – user3360972 Sep 17 '15 at 07:06
  • Your question would require a lengthy list of "try this", "try that", "have you?", "what's the?", and "oh, please show" comments. And while revealing a few relevant details (compare the dupe) would perhaps make this answerable, it still wouldn't be useful to other users. You're expecting a bit too much support there. (See the reference on using PHPMailer however.) – mario Sep 17 '15 at 07:14

0 Answers0