0

I am trying to tie my html form to a PHP mailer and for some reason the form inputs are not storing in my variables. I have tried searching all over and I cannot see what I am doing wrong. Any help would be greatly appreciated.

Form handler:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = trim($_POST["name"]);
    $email = trim($_POST["email"]);
    $date = trim($_POST["date"]);
    $guests = trim($_POST["guests"]);
    $description = trim($_POST["description"]);
}

Form:

<form role="form" class="text-center" method="POST" enctype="text/plain" action="index.php">
    <div class="form-group">
      <label for="name">Nombre</label>
      <input type="text" class="form-control" id="name" name="name">
    </div>
    <div class="form-group">
      <label for="email">Correo Electrónico</label>
      <input type="email" class="form-control" id="email" name="email">
    </div>
    <div class="form-group">
      <label for="date">Fecha del Evento</label>
      <input type="date" id="date" class="form-control" name="date">
    </div>
    <div class="form-group">
      <label for="guests">Número de Huéspedes</label>
      <select class="form-control" id="guests" name="guests">
        <option>1 - 2</option>
        <option>3 - 4</option>
        <option>5 - 6</option>
        <option>7 - 8</option>
      </select>
    </div>
    <div class="form-group">
      <label for="description">Descripción de Evento</label>
      <textarea class="form-control" id="description" rows="3" name="description"></textarea>
    </div>
    <div style="display: none;">
      <label for="address">Address</label>
      <input type="text" class="form-control" id="address" name="address">
    </div>
    <input type="submit" class="btn btn-default" value="Enviar">
</form>
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
ZBarnes
  • 3
  • 2

1 Answers1

1

For PHP text/plain is not a valid value for enctype in <form>

Take a look here

Community
  • 1
  • 1
Pep Lainez
  • 949
  • 7
  • 12
  • 1
    It is, just not for PHP. – AbraCadaver May 15 '14 at 19:04
  • I've never ever seen an `enctype` other than `"multipart/form-data"`. Is anything else valid in a form? – Rudie May 15 '14 at 19:05
  • @Rudie I believe the default is `application/x-www-form-urlencoded`, but this format is not good to upload files. At least not to PHP. Thats why, when uploading files, the enctype `multipart/form-data` is specified. – Havenard May 15 '14 at 19:07
  • @AbraCadaver, you are right... I was to fast hitting post :P – Pep Lainez May 15 '14 at 19:08
  • I changed the `enctype` to `application/x-www-form-urlencoded` but it still doesn't seem to be taking any of the data. – ZBarnes May 15 '14 at 21:48