Click here to Skip to main content
15,911,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I want to create a form that accepts multiple input at a single time. I'm not worried about the mySQL commands those are simple and easy to fix.
What I am focusing on is the actual form and the php code that will be used to send the data into the database.

Do I need to create an array that will hold the different variables, is there any way I can create a foreach loop that will then reduce the lines of code... Do the number of lines of code matter????

I am new to php I only learned html and css, and I have learned a little from java , python, and now php..... I am focused on mastering PHP I just need a little guidance.

What I have tried:

Well I have tried coding this by repeating the same line of code with a different name here is a snippet so you know what I mean..

<input type="text"name="name10" />
<input type="text" name="amount10" />
A <input type="radio" name="type10"/>
b <input type="radio" name="type10"/>
c <input type="radio" name="type10"/>



The code is repeated over and over again



$name10 = $_POST['name10'] $type10 = $_POST['type10'] $amount10 = $_POST['amount10'];
$sql="INSERT INTO table 1(name, type, amount)
VALUES('$name10', '$type10' ,'$amount10');";


Same deal with the php code and the sql to insert every value input into the form... Am I doing this right???
Posted
Updated 15-Jul-16 3:59am
Comments
Mohibur Rashid 14-Jul-16 21:57pm    
I haven't got the repeat part. What are you repeating?
saeed rajabi 15-Jul-16 9:56am    
unclear,
write an example

1 solution

C#
i think you forgot this :
if(isset($_POST['your submit name']))
{
//do something
}
else
{
// do the other
}

and after that you should do this to your form :
HTML
<form  action="" method="post" enctype="multipart/form-data">....</form>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900