Profpatsch
Profpatsch

Reputation: 5058

HTML5 form isn’t submitting any data

I’ve got the following HTML5 form:

  <form action="/desired_worktimes/submit" method="post">
    <div class="month">
      <h2>October</h2>
      <div class="week">
        <h3>2013-10-21–2013-10-21</h3>    
        <p>
          <span>Mon</span>

          <label for="from-2013-10-21">From</label>
          <input type="time" id="from-2013-10-21" />

          <label for="to-2013-10-21">To</label>
          <input type="time" id="to-2013-10-21" />

          <label for="free-2013-10-21">Free</label>
          <input type="checkbox" id="free-2013-10-21" />

        </p>
      </div>
    </div>

  <button type="submit">Submit</button>
  </form>

When I hit submit, no data arrives at the post endpoint. I tested the server with Postman, it displays all form data submitted to the endpoint, but with the above form, I get nothing.

What is wrong with the form?

Upvotes: 0

Views: 1589

Answers (2)

david
david

Reputation: 3218

You must use name attribute for each input. Example: <input type="time" id="from-2013-10-21" name="abc"/>. To get the value of these input, just use $_POST['abc'].

Upvotes: 4

Joke_Sense10
Joke_Sense10

Reputation: 5402

Check the last line of your code and also you have not included name attribute in any of your form fields:

Instead of this:

<button type="submit">Submit</button>

It should have been this:

<input type="submit" value="submit">

Upvotes: 2

Related Questions