Ik heb een Formuliertje gemaakt, maar voordat ik op het submit buttontje klik worden de gegevens al in de database gezet. Weet iemand misschien hoe dit komt en heeft iemand hier misschien een oplossing voor?
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
| <?php mysql_connect("localhost", "root", "") or die("Error: Can't Connect MySQL Server"); mysql_select_db("xsf") or die("Error: Can't Select Database"); ?> <form method="post" action="<? echo("$PHP_SELF"); ?>"> <table width="50%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="17%">Vraag:</td> <td width="83%"> <input name="vraag" type="text" size="50" style="background-color: #6EBC95; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"> </td> </tr> <tr> <td>Keuze 1:</td> <td><input type="text" name="keuze1" size="50" style="background-color: #6EBC95; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"></td> </tr> <tr> <td>Keuze 2:</td> <td><input type="text" name="keuze2" size="50" style="background-color: #6EBC95; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"></td> </tr> <tr> <td>Keuze 3:</td> <td><input type="text" name="keuze3" size="50" style="background-color: #6EBC95; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"></td> </tr> <tr> <td>Keuze 4:</td> <td><input type="text" name="keuze4" size="50" style="background-color: #6EBC95; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"></td> </tr> <tr> <td>Keuze 5:</td> <td><input type="text" name="keuze5" size="50" style="background-color: #6EBC95; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"></td> </tr> </table> <INPUT TYPE="HIDDEN" NAME="stage" value="1"> <input type="submit" value="Wijzig Poll!" style="background-color: #81C1E3; font-family: Verdana; font-size: 12 px; border-style: solid; border-color: #000000"> </form> <? if(!isset($_POST["stage"])) { print ""; }else{ /* Pakt waardes van de form en zet ze om in normale variabelen */ $vraag = $_POST["vraag"]; $keuze1 = $_POST["keuze1"]; $keuze2 = $_POST["keuze2"]; $keuze3 = $_POST["keuze3"]; $keuze4 = $_POST["keuze4"]; $keuze5 = $_POST["keuze5"]; /* Voegt waardes aan database toe */ $sql = "INSERT INTO poll (vraag, keuze1, keuze2, keuze3, keuze4, keuze5) VALUES ('$vraag', '$keuze1', '$keuze2', '$keuze3', '$keuze4', '$keuze5')"; $result = mysql_query($sql) or die(mysql_error()); echo("Your Server has been added."); } ?> |