Het probleem is dat ie de cookie niet aanmaakt, weet iemand waarom?>
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
| <? mysql_connect() or die ("Database Error"); $result=mysql_db_query("wijnands","SELECT * FROM producten ORDER BY naam"); $aantal_rijen=mysql_num_rows($result); if ($push == "ja") { global $mandje; // Dit is het cookie if ($mandje) { if (ereg("$id\(([0-9]+)\)", $mandje, $regs)) { /* Product bestaat al, het 'huidige' aantal staat nu in $regs[1] */ $aantal = $aantal + $regs[1]; $mandje = ereg_replace( "^(.*)($id)\([0-9]+\)(.*)$", "\\1\\2($aantal)\\3", $mandje); } else { /* Artikel bestaat nog niet, dus gewoon achteraan toevoegen. */ $mandje .= "-$id($aantal)"; } } else { // Maak het koekje aan! $mandje = "$id($aantal)"; echo"$id"; echo"$aantal"; } // Schrijf het cookie (bewaar het maximaal 1 jaar) setcookie("mandje", $mandje, time() + 10000, "/"); } ?> <table border="0" cellpadding="5" cellspacing="0"> <?php for($teller=0;$teller<$aantal_rijen;$teller++) { $rij=mysql_fetch_row($result); echo " <tr> <form action=\"test.php\" method=\"post\"> <input type=\"hidden\" name=\"push\" value=\"ja\"> <input type=\"hidden\" name=\"id\" value=\"$rij[0]\"> <td>item $rij[1]</td> <td>prijs $rij[2]</td> <td><input type=\"text\" name=\"aantal\"><td> <td><input type=\"submit\" name=\"action\" value=\"In winkelwagen\"><td> </form> </tr> "; } ?> </table> ?> |