Fil 1, new_vote.php:
<html>
<body>
<form action="new_vote2.php" method="post">
<b>Skapa omrvstning. steg 1</b><br>
<table>
<tr>
<td class="Default">Antal Fregor</td>
<td class="Default">
<input class="Default" maxlength="100" name="row" type="" size="2" value="">
</td>
</td>
</tr>
<tr>
<td>
<input type=submit value="Vidare">
</td>
</tr>
</table>
</form>
</body>
</html>
******************************************************************
Fil 2 new_vote2.php
<html>
<body>
<?php
$start = 0;
if ($row < 1 || $row > 15) {
echo "Meste vara ett heltal mellan 1-15";
}
else {
echo "<form action=\"new_vote3.php\" method=\"post\">";
echo "<table>";
echo "<b>Skapa omrvstning. steg 2</b>";
echo "<tr>";
echo "<td class=\"Default\">Titel:</td>";
echo "<td class=\"Default\">";
echo "<input class=\"Default\" maxlength=\"100\" name=\"titel\" type=\"\" size=\"20\" value=\"\">";
echo "</td>";
echo "</td>";
echo "</tr>";
while ($start < $row)
{
$temp = $start + 1;
echo "<tr>";
echo "<td class=\"Default\">Frega $temp</td>";
echo "<td class=\"Default\">";
echo "<input class=\"Default\" maxlength=\"100\" name=\"qu$temp\" type=\"\" size=\"45\" value=\"\">";
echo "</td>";
echo "</td>";
echo "</tr>";
$start++;
}
echo "<tr>";
echo "<td>";
echo "<input type=\"hidden\" name=\"row\" value=\"$row\"><input type=submit value=\"Spara\">$row";
echo "<input type=submit value=\"Avbryt\">";
echo "</td>";
echo "</tr>";
echo "</table></form>";
}
?>
</body>
</html>
-------------------------------------------------------------------------------------
Fil 3, new_vote3.php
<html>
<body>
<?php
mysql_connect("localhost","root","pass");
@mysql_select_db("webb") or die("Kunde inte konnecta till databasen");
$i=0;
$id=4;
while($i < $row) {
$temp=$i+1;
$add = "insert into vote_d(id, answers) values('$id','$qu$temp')";
$i++;
$result = mysql_query($add);
}
echo mysql_error();
mysql_close();
?>
</body>
</html>
Det går inte att få värdet från new_vote2.php till databasen utan massa ifsatser, på det sättet.. nå förslag?