Form fields are empty in the mail that is sent

4

I have a form in php that works when uploading it to the server (it sends mail), but the fields that the user fills out go blank (with which he does not send any information in reality)

this is the form

<form action="contact_process.php" method="post" id="contactForm">
<div class="overlay">
    <div class="border">
    <div class="ser-in-box"><input class="form-control datepicker-example8" placeholder="Fecha de Llegada" type="text"></div>
    <div class="ser-in-box"><input type="text" class="form-control datepicker-example8" placeholder="Fecha de Salida"></div>
    <div class="ser-in-box">   
    <div class="select-box">
                            <select class="select-menu" name="selectMenu">
                                <option value="default">Escoja su Espacio</option>  
                                <option value="1">1</option>    
                                <option value="2">2</option>    
                                <option value="3">3</option>    
                                <option value="4">4</option>    
                            </select>
                    </div>
    </div>
<div class="ser-in-box">
     <div class="select-box">
                            <select class="select-menu" name="selectMenu">
                                <option value="default">Personas</option>  
                                <option value="1">1</option>    
                                <option value="2">2</option>    
                                <option value="3">3</option>    
                                <option value="4">4</option>    
                            </select>
                    </div></div>
<div class="ser-in-box chk-button"><button type="submit" class="res-btn">Haga Su Reserva</button></div>
    </div>

</div>
</form>

y este el php que deberia hacerlo funcionar y por tanto enviar la informacion

<?php

    $to = "[email protected]";

    $name = $_REQUEST['Nombre'];
    $from = $_REQUEST['E-mail'];
    $arival_date = $_REQUEST['Fecha de llegada'];
    $departure_date = $_REQUEST['Fecha de salida'];
    $chooseAdults = $_REQUEST['Escoja su Espacio'];
    $chooseChildren = $_REQUEST['Personas'];
    $message = $_REQUEST['Su mensaje'];


    $headers = "From: " . $from . "\r\n";
    $headers .= "Reply-To: ". $from . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    $subject = "Solicitud de Reserva";

    $body = "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><title>Industrial Mail</title></head><body>";
    $body .= "<table style='width: 100%;'>";
    $body .= "<tbody><tr><td style='border:none;' colspan='2'>Equipo de Reservas, <br /> <br />Teneis una nueva solicitud de reserva <br />Los detalles de la misma figuran a continuacion:</td></tr>";
    $body .= "<tr><td style='border:none;height:10px'>&nbsp;</td><td style='border:none;'>&nbsp;</td></tr>";
    $body .= "<tr><td style='border:none;'>Nombre</td><td style='border:none;'>{$name}</td></tr>";
    $body .= "<tr><td style='border:none;'>E-mail</td><td style='border:none;'>{$from}</td></tr>";
    $body .= "<tr><td style='border:none;'>Fecha de llegada:</td><td style='border:none;'>{$arival_date}</td></tr>";
    $body .= "<tr><td style='border:none;'>Fecha de salida:</td><td style='border:none;'>{$departure_date}</td></tr>";
    $body .= "<tr><td style='border:none;'>Escoja su Espacio:</td><td style='border:none;'>{$chooseAdults}</td></tr>";
    $body .= "<tr><td style='border:none;'>Personas</td><td style='border:none;'>{$chooseChildren}</td></tr>";
    $body .= "<tr><td style='border:none;'>Su mensaje</td><td style='border:none;'>{$message}</td></tr>";
    $body .= "<tr><td style='border:none;height:10px'>&nbsp;</td><td style='border:none;'>&nbsp;</td></tr>";
    $body .= "<tr><td style='border:none;'>Gracias</td><td style='border:none;'></td></tr>";
    $body .= "<tr><td style='border:none;'>El equipo de Pazo Catoira</td><td style='border:none;'></td></tr>";


    $body .= "</tbody></table>";
    $body .= "</body></html>";

    $send = @mail($to, $subject, $body, $headers);

    if($send)
    {
        echo 'Gracias por contactar con Pazo Catoira. Recibirá su respuesta a la mayor brevedad posible';
    }
    else
    {
        echo 'Ocurrio un error durante el proceso de envío. Por favor intentelo de nuevo';
    }
?>

Sure it will be a simple thing but I do not know how to solve it after trying everything

Thanks

    
asked by Antonio 15.03.2018 в 22:06
source

2 answers

1

In the html you are missing the name attribute:

<input name="fecha_llegada" class="form-control datepicker-example8" placeholder="Fecha de Llegada" type="text">

In php, $ _REQUEST refers to this attribute:

$_REQUEST['fecha_llegada']

Do not use spaces, or other strange characters.

    
answered by 15.03.2018 в 22:25
1

Greetings the detail is in the following lines:

    $arival_date = $_REQUEST['fecha_llegada'];
    $departure_date = $_REQUEST['fecha_salida'];
    $chooseAdults = $_REQUEST['escoja_espacio'];
    $chooseChildren = $_REQUEST['Personas'];
    $message = $_REQUEST['Su_mensaje'];

Those spaces do not go, that is to say the spaces between the words because it causes confusion and could be interpreted as a name of input different from the one you declared in your HTML.

To yourself those names should be the same ones that you use in your HTML is to say the variables that you occupy at the end of all your code have; try as I declared them and likewise name them on your input tags

    
answered by 15.03.2018 в 22:49