PDA

View Full Version : How would I submit this?



Moh
08-07-2008, 04:38 PM
Well I am using for statements to add multiple information into a database.

So if you want to add 2 items, it will only display 2 input boxes, if you want to add 8 it will display 8.

Well, I have got stuck at entering the information into the database.

How do I make it insert the information submitted using this way?

My file is:


<?php

$act = $_GET["act"];

if($act == "") {
$act = "form";
}

if($act == "form") {
echo("<form method=\"post\" action=\"?act=add\">
<strong>Number of options</strong> (Max 8):<br>
<input type=\"text\" name=\"num\" id=\"num\" size=\"20\"></input>
<input type=\"submit\" name=\"submit\" value=\"Next\"></input></form>");
}

if($act == "add") {
$num = $_POST["num"];
if($num > 8) {
$num = "8";
}
if($num == "" OR $num == "0") {
$num = "2";
}
echo("<form method=\"post\" action=\"?act=submit\">
<input type=\"hidden\" name=\"num\" id=\"num\" size=\"20\" value=\"$num\"></input>\n");
for($i = 1;; $i ++) {
if ($i > $num) {
break;
}
echo ("<strong>Option $i</strong>:<br>
<input type=\"text\" name=\"opt$i\" id=\"opt$i\" size=\"20\"></input><br><br>\n");
}
echo("<input type=\"submit\" name=\"submit\" value=\"Add Poll\"></input></form>");
}

if($act == "submit") {

// Code Here

}
?>

Want to hide these adverts? Register an account for free!