MYSQL/PHP: Inserting data via HTML form, same "input name"

Posted by Camen on Stack Overflow See other posts from Stack Overflow or by Camen
Published on 2014-08-21T10:14:58Z Indexed on 2014/08/21 10:20 UTC
Read the original article Hit count: 181

Filed under:
|
|
|

I'm new to MySQL and as a learning project I'd like to make a recipe database. I'd like to the user to be able to enter ingredients through a simple HTML form but I'm stuck in how to label the form so that I can enter several ingredients into the database at once.

I'd like to do something like this:

<form method="post" action="insert.php">
Ingredient 1: <input type="text" name="ingredient"><br />
Ingredient 2: <input type="text" name="ingredient"><br />
Ingredient 3: <input type="text" name="ingredient"><br />
<input type="submit" value="Submit">
</form>

When I do this, I add rows to the table but they're all empty. I know it's got something to do with me using "ingredient" (the table value where I want to add the ingredient name) several times in the form, but I just don't know how to solve it.

I would absolutely love some input on how to make it work.

© Stack Overflow or respective owner

Related posts about php

Related posts about html