i have currently 5 input name box which i want to insert into mysql database.
Here is my code with basic knowledge of php i have, but know there would be any better way of code as i am just a noob.
<form action="result.php" method="POST">
<input type="text" name="name1" value="" />
<input type="text" name="name2" value="" />
<input type="text" name="name3" value="" />
<input type="text" name="name4" value="" />
<input type="text" name="name5" value="" />
</form>
on result.php i am using this mysql code
mysql_query("INSERT INTO users (name1, name2, name3. name4, name5)
VALUES ('$_POST["name1"]', '$_POST["name2"]', '$_POST["name3"]',
'$_POST["name4"]', '$_POST["name5"]'");
Suppose if there are 1000 fields how do i manage it ?
The code you’ve posted should be failing and generating errors – but you’ve made no mentioned of these. Is it failing? Or is this not the code you are using?
(you’ve tried to embed double quotes without escaping them, associative indexes inside double quotes should not have additional quotes around them, you’ve used a period as a field seperator).
Normalise your database.