Php 7 bestel script

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ronnie Vos

Ronnie Vos

01/04/2019 16:45:12
Quote Anchor link
Hallo,

Wij hebben een bestel systeem is omgezet naar php 7 werkte altijd perfect tot de laatste 2 dagen.
Als iemand een bestelling invult en verstuurd krijg je gelijk dit bericht:
Er is een fout opgetreden

Deze bestelling is al bevestigd

Klik hier om terug te gaan

Terwijl dat niet zo is wie kan evt zien wat er fout gaat?

bestelling_bevestigen.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?

require("config.php");
include("ubb.php");

echo " <head>";
echo " <link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\" media=\"screen\" />";
echo " </head>";

$select = "SELECT * FROM bestellingen  WHERE `bestelcode`='" . $_GET[id] . "' ORDER by bestelling_id";
$query = mysqli_query($con,$select);
$aantal = mysqli_num_rows($query);

$select1 = "SELECT * FROM bestelinfo  WHERE `bestelcode`='" . $_GET[id] . "'";
$query1 = mysqli_query($con,$select1);
$aantal1 = mysqli_num_rows($query1);
$list1 = mysqli_fetch_object($query1);

$select2 = "SELECT * FROM bestelinfo WHERE bestelcode='" . $_GET[id] . "' AND bevestigd='nee'";
$query2 = mysqli_query($con,$select2);
$bestaat = mysqli_num_rows($query2);

if($_POST['bevestigen']) {
   echo "<center><b>Status:</b>";

  $dbres                    = mysqli_query($con,"SELECT * FROM `bestelinfo` WHERE `bestelcode`='" . $_GET[id] . "' AND `bevestigd`='nee'");
    if($data = mysqli_fetch_object($dbres)) {
    mysqli_query($con,"UPDATE `bestelinfo` SET `bevestigd`='ja' WHERE `bestelcode`='" . $_GET[id] . "' AND `bevestigd`='nee'");
      print "  <tr><td class=\"mainTxt\">Bestelling is bevestigd, u heeft een email ontvangen met verdere informatie</td></tr>\n";
      echo '<META HTTP-EQUIV="refresh" CONTENT="3;URL=http://eetsjopbaloe.com/index.php">';
        
        $headers = 'From: Eetsjop Baloe <[email protected]>' . "\r\n" .
    'Content-type: text/html; charset=iso-8859-1\r\n' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
        
        $mail_body = "<i>De volgende email werd op " . date("d-m-Y") . " om " . date("H:i") . " uur gestuurd.</i><br><br>";
        $mail_body .= "Beste $data->naam<br><br>";
        $mail_body .= "Bedankt voor uw bestelling.<br>Binnen <b>15 minuten</b> zult u een bevestigings mail uit onze keuken in uw mailbox krijgen.<br>In die bevestingsmail zal de exacte tijdstip van afhalen komen te staan.<br>U heeft aangegeven de bestelling $data->tijdstip_afhalen op te willen halen, hier wordt uiteraard rekening mee gehouden.<br><br><b>Let op!<br>Indien uw bestelling boven de 20 euro is wordt u gebeld ter bevestiging.<br>Indien u niet opneemt wordt de bestelling automatisch geannuleerd.</b><br><br>Hierbij hopen wij u voldoende geïnformeerd te hebben.<br><br>";
       $mail_body .= "Met vriendelijke groet,<br><br>Team Eetsjop Baloe</p>";
        
        $subject = "Baloe Bestelling";
        
        mail($data->email, $subject,  $mail_body, $headers);

    }

    else
      echo "<br><br>Deze bestelling is al eerder bevestigd.<br>U kunt een bestelling maar 1x bevestigen om misverstanden te voorkomen</center>";
      echo '<META HTTP-EQUIV="refresh" CONTENT="3;URL=http://eetsjopbaloe.com/index.php">';
  }
else{
      
            if($bestaat == 'ja')
        {

            echo "<b>Er is een fout opgetreden</b><br><br>";
            echo "Deze bestelling is al bevestigd<br><br> <a class=\"linkje1\" href=\"javascript:history.go(-1)\">Klik hier om terug te gaan</a>";    
        }
else{
        
if ($aantal != 0)
{


  echo "<center><p class=\"style2\">Controleer de bestelling voordat u deze bevestigd</p></center>";
    echo "<br><table align=\"center\" id=\"tabel_gegevens\" width=\"70%\" cellpadding=\"10\" cellspacing=\"10\">";
    echo "<tr></td><td><b>De door uw bestelde producten:</b></td><td><b>Aantal keer:</b></td><td><b>Prijs per stuk:</b></td><td><b>Totaal:</b></td></tr>";

    while ($list = mysqli_fetch_object($query))
    {

        echo "<tr class=\"td_style_bevestig\"><td>$list->omschrijving: $list->bakje</td><td>$list->aantal</td><td>€$list->prijs</td><td>$list->totaalkolom</td></tr>";
    }

    if ($list1->totaalprijs >= 20.00){
        $bt    = "<b>Deze bestelling wordt telefonisch bevestigd<br>Indien u niet opneemt wordt de bestelling automatisch geannuleerd.</b>";
  }

  if ($list1->totaalprijs <= 20.00){
        $bt    = "<b>Deze bestelling wordt per e-mail bevestigd";
  }

    echo "<tr><td></td><td><p class=\"style1\">Totaal prijs:</p></td><td><p class=\"style1\">€$list1->totaalprijs</p></td><td></td></tr>";
    echo "</table>";
    echo "<br><table align=\"center\" id=\"tabel_gegevens\" width=\"70%\" cellpadding=\"10\" cellspacing=\"10\">";
    echo "<tr></td><td><b>Persoonlijke gegevens</b></td><td width=\"40%\"><b>Door u ingevuld</b></td></tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Naam:</td>";
    echo "<td>$list1->naam</td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td>Email:</td>";
    echo "<td>$list1->email</td>";
    echo "</tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Telefoon nummer:</td>";
    echo "<td>$list1->telnummer</td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td>Gewenste tijdstip van afhalen:</td>";
    echo "<td>$list1->tijdstip_afhalen</td>";
    echo "</tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Extra opmerkingen:</td>";
    echo "<td class=\"extra\">";
    echo ubb($list1->extra);
    echo "</td>";
    echo "</tr>";
        echo "<tr class=\"td_style_none\">";
    echo "<td><b>Bevestigingswijze:</b></td>";
    echo "<td>". $bt ."</td>";
    echo "</tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td><p class=\"style1\">Deze bestelling klopt en ik wil deze graag versturen</p></td>";
    echo "<td><form method=\"POST\" onSubmit=\"return confirm('Weet u het zeker?')\"><input name=\"bevestigen\" type=\"submit\" class=\"H1\" value=\"Bevestig de bestelling\" /></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td><p class=\"style1\">Deze bestelling klopt niet en ik wil graag terug</p></td>";
    echo "<td><input type=\"button\" class=\"H1\" value=\"Annuleer deze bestelling\" onclick=\"location.href = 'http://bestellen.eetsjopbaloe.com/annuleer.php?id=" . $_GET[id] . "'\" /></td>";
    echo "</tr>";
    echo "</form></table>";
}

else{
    $select = "SELECT * FROM bestelinfo";
  $query = mysqli_query($con,$select);
    mysqli_query($con,"DELETE FROM `bestelinfo` WHERE `bestelcode`='" . $_GET[id] . "'");
    echo "<center><p class=\"style2\">Er is geen bestelling gevonden<br>Probeer het opnieuw</p></center>";
    echo '<META HTTP-EQUIV="refresh" CONTENT="3;URL=http://eetsjopbaloe.com/index.php">';
}
}
}

?>


index.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
   <center><table id="myTable">
    <tr><td>
<?php
opcache_reset();

//error_reporting(E_ALL); ini_set('display_errors', 1);
require("config.php");
echo "<head>";
echo " <link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\" media=\"screen\" />";
echo " <script type=\"text/javascript\" src=\"scripts/calculations.js\"></script>";
echo "<script language=\"JavaScript\" type=\"text/JavaScript\">
function popup(page,title,width,height) {
 var winl = (screen.width - width) / 2;
 var wint = (screen.height - height) / 2;
 window.open(''+page,''+title,'width='+width+',height='+height+',top='+wint+',left='+winl+',resizable=no,scrollbars=no,toolbar=no');
}
function getKeyCode(eventObject)
        {
            if (!eventObject) keyCode = window.event.keyCode; //IE
            else keyCode = eventObject.which;   //Mozilla
            return keyCode;
        }
function onlyNumeric(eventObject)
        {
            keyCode = getKeyCode(eventObject);
            if (((keyCode > 31) && (keyCode < 48)) || ((keyCode > 57) && (keyCode < 127)))
            {
                    if (!eventObject) window.event.keyCode = 0; //IE
                    else eventObject.preventDefault(); //Mozilla
                    return false;
            }
        }


</script>"
;
echo '<style type="text/css">
  #uitklap1 {
    display: none;
    background-color: #FFFFFF;
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    border-color:gray;
    padding: 7px;
    }#uitklap2 {
    display: none;
    background-color: #FFFFFF;
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    border-color:gray;
    padding: 7px;
    }#uitklap3 {
    display: none;
    background-color: #FFFFFF;
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    border-color:gray;
    padding: 7px;
    }#uitklap4 {
    display: none;
    background-color: #FFFFFF;
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    border-color:gray;
    padding: 7px;
    }#uitklap5 {
    display: none;
    background-color: #FFFFFF;
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    border-color:gray;
    padding: 7px;
    }#uitklap6 {
    display: none;
    background-color: #FFFFFF;
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    border-color:gray;
    padding: 7px;
    }
    </style> '
;
echo " </head>";
echo '<body>';
echo " <form method=post action=\"#\" name='order'>";

$select = "SELECT * FROM producten";

if ($con) {
    $query = mysqli_query($con,$select);
    $aantal = mysqli_num_rows($query);
    $list = mysqli_fetch_object($query);
}
else {
    $aantal = null;    
}

function
MaakSleutel($lengte = 10) {  
    return random_int(pow(10, $lengte - 1), pow(10, $lengte) - 1);
}

function
opties($begin, $aantal){
    $teller = $begin;
    $maxAantal = $aantal;
    while($teller < $maxAantal){
        $opties .= '<option value="'.$teller.'">'.$teller.'</option>';
        $teller++;
    }

    return $opties;
}

function
besteltijd_uur($begin, $aantal){
    $teller = $begin;
    $maxAantal = $aantal;
    while($teller < $maxAantal){
        if($teller == ''){
     $opties .= '<option selected="selected" value="'.$teller.'">'.$teller.'</option>';
}
else{
     $opties .= '<option value="'.$teller.'">'.$teller.'</option>';
}

$teller++;

    }

    return $opties;
}

function
besteltijd_min($begin, $aantal){
    $teller = $begin;
    $maxAantal = $aantal;
    while($teller < $maxAantal){
        if($teller == ''){
     $opties .= '<option selected="selected" value="'.$teller.'">'.$teller.'</option>';
}
else{
     $opties .= '<option value="'.$teller.'">'.$teller.'</option>';
}

$teller++;

    }

    return $opties;
}



function
dotToComma($bedrag){
    return str_replace('.', ',', $bedrag);
}

function
maakBedrag($bedrag){
    $bedrag2 = explode(",", $bedrag);
    $count = strlen($bedrag2[1]);
    if($count < 2){
        if($count == 0){
            $bedrag = $bedrag.",00";
        }
else{
            $bedrag = $bedrag."0";
        }
    }

    return $bedrag;
}


if (isset($_POST["Bestellen"]) && $_POST["Bestellen"]) {
      $activatiecode = MaakSleutel();
    $datum = date("Y-m-j");

if(strlen($_POST['naam']) < 3) {
    $error_msg ="- Voer astublieft uw naam in.<br> Dit moet minstens 3 letters lang zijn.<br>";
}


if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $error_msg .="- Voer astublieft een geldig email adres in.<br>";
}


if(strlen($_POST['telnummer']) < 10 || strlen($_POST['telnummer']) > 10) {
    $error_msg .="- Een telefoonnummer moet uit 10 cijfers bestaan.<br>";
}

  
if(!empty($error_msg))
    {

    //Een van de velden werd niet goed ingevuld
    echo "<b>Er is 1 of er zijn meerdere fouten opgetreden.</b><br><br>";
    echo $error_msg;
    echo "<br>Klik alstublieft op <a href=javascript:history.back(1)>Ga terug</a> en vul alle velden correct in.<br><br>";
    }

else
    {
        $teller = 1;
        $toaal = 0;
        foreach($_POST['pt'] as $pw){    
            $sql = 'SELECT * FROM producten_patat WHERE productid ='. $teller .' ORDER by productid';
            $res = mysqli_query($con,$sql);
            while($product = mysqli_fetch_array($res)){
                $productPrijs = $product['prijs'];
                $productAantal = $pw;
                $subtotaal = $productPrijs * $productAantal;
                $totaal = $totaal + $subtotaal;
                if($productAantal != 0){
                    $insert = "INSERT INTO bestellingen (bestelling_id, bestelcode, omschrijving, aantal, prijs, totaalkolom) VALUES ('', '" .$activatiecode. "', '" .$product['omschrijving']. "', '" .$productAantal. "', '" .maakBedrag(dotToComma($product['prijs'])). "', '" .maakBedrag(dotToComma($subtotaal)). "')";
              $query = mysqli_query($con,$insert);
              $id = mysqli_insert_id();
                }
            }
            
            $teller++;
        }

        $teller = 1;
        $toaal = 0;
        foreach($_POST['sn'] as $pw){    
            $sql = 'SELECT * FROM producten_snacks WHERE productid ='. $teller .' ORDER by productid';
            $res = mysqli_query($con,$sql);
            while($product = mysqli_fetch_array($res)){
                $productPrijs = $product['prijs'];
                $productAantal = $pw;
                $subtotaal = $productPrijs * $productAantal;
                $totaal = $totaal + $subtotaal;
                if($productAantal != 0){
                    $insert = "INSERT INTO bestellingen (bestelling_id, bestelcode, omschrijving, aantal, prijs, totaalkolom) VALUES ('', '" .$activatiecode. "', '" .$product['omschrijving']. "', '" .$productAantal. "', '" .maakBedrag(dotToComma($product['prijs'])). "', '" .maakBedrag(dotToComma($subtotaal)). "')";
              $query = mysqli_query($con,$insert);
              $id = mysqli_insert_id();
                }
            }
            
            $teller++;
        }

        $teller = 1;
        $toaal = 0;
        foreach($_POST['br'] as $pw){    
            $sql = 'SELECT * FROM producten_broodjes WHERE productid ='. $teller .' ORDER by productid';
            $res = mysqli_query($con,$sql);
            while($product = mysqli_fetch_array($res)){
                $productPrijs = $product['prijs'];
                $productAantal = $pw;
                $subtotaal = $productPrijs * $productAantal;
                $totaal = $totaal + $subtotaal;
                if($productAantal != 0){
                    $insert = "INSERT INTO bestellingen (bestelling_id, bestelcode, omschrijving, aantal, prijs, totaalkolom) VALUES ('', '" .$activatiecode. "', '" .$product['omschrijving']. "', '" .$productAantal. "', '" .maakBedrag(dotToComma($product['prijs'])). "', '" .maakBedrag(dotToComma($subtotaal)). "')";
              $query = mysqli_query($con,$insert);
              $id = mysqli_insert_id();
                }
            }
            
            $teller++;
        }

        $teller = 1;
        $toaal = 0;
        foreach($_POST['dr'] as $pw){    
            $sql = 'SELECT * FROM producten_drinken WHERE productid ='. $teller .' ORDER by productid';
            $res = mysqli_query($con,$sql);
            while($product = mysqli_fetch_array($res)){
                $productPrijs = $product['prijs'];
                $productAantal = $pw;
                $subtotaal = $productPrijs * $productAantal;
                $totaal = $totaal + $subtotaal;
                if($productAantal != 0){
                    $insert = "INSERT INTO bestellingen (bestelling_id, bestelcode, omschrijving, aantal, prijs, totaalkolom) VALUES ('', '" .$activatiecode. "', '" .$product['omschrijving']. "', '" .$productAantal. "', '" .maakBedrag(dotToComma($product['prijs'])). "', '" .maakBedrag(dotToComma($subtotaal)). "')";
              $query = mysqli_query($con,$insert);
              $id = mysqli_insert_id();
                }
            }
            
            $teller++;
        }

        $teller = 1;
        $toaal = 0;
        foreach($_POST['sa'] as $pw){    
            $sql = 'SELECT * FROM producten_sausjes WHERE productid ='. $teller .' ORDER by productid';
            $res = mysqli_query($con,$sql);
            while($product = mysqli_fetch_array($res)){
                $productPrijs = $product['prijs'];
                $productAantal = $pw;
                $subtotaal = $productPrijs * $productAantal;
                $totaal = $totaal + $subtotaal;
                if($productAantal != 0){
                    $insert = "INSERT INTO bestellingen (bestelling_id, bestelcode, omschrijving, aantal, prijs, totaalkolom) VALUES ('', '" .$activatiecode. "', '" .$product['omschrijving']. "', '" .$productAantal. "', '" .maakBedrag(dotToComma($product['prijs'])). "', '" .maakBedrag(dotToComma($subtotaal)). "')";
              $query = mysqli_query($con,$insert);
              $id = mysqli_insert_id();
                }
            }
            
            $teller++;
        }

        $teller = 1;
        $toaal = 0;
        foreach($_POST['me'] as $pw){    
            $sql = 'SELECT * FROM producten_menus WHERE productid ='. $teller .' ORDER by productid';
            $res = mysqli_query($con,$sql);
            while($product = mysqli_fetch_array($res)){
                $productPrijs = $product['prijs'];
                $productAantal = $pw;
                $subtotaal = $productPrijs * $productAantal;
                $totaal = $totaal + $subtotaal;
                if($productAantal != 0){
                    $insert = "INSERT INTO bestellingen (bestelling_id, bestelcode, omschrijving, aantal, prijs, totaalkolom) VALUES ('', '" .$activatiecode. "', '" .$product['omschrijving']. "', '" .$productAantal. "', '" .maakBedrag(dotToComma($product['prijs'])). "', '" .maakBedrag(dotToComma($subtotaal)). "')";
              $query = mysqli_query($con,$insert);
              $id = mysqli_insert_id();
                }
            }
            
            $teller++;
        }

        $insert = "INSERT INTO bestelinfo (id, bestelcode, bevestigd, naam, email, telnummer, tijdstip_afhalen, totaalprijs, extra, datum) VALUES ('', '" .$activatiecode. "', 'nee', '" . $_POST[naam] . "', '" . $_POST[email] . "', '" . $_POST[telnummer] . "', '" . $_POST[uur] . ":" . $_POST[minuten] . "', '" .maakBedrag(dotToComma($totaal)). "', '" . $_POST[extra] . " " . $_POST[menu_extra] . "', NOW())";
        $query = mysqli_query($con,$insert);
        echo '<META HTTP-EQUIV="refresh" CONTENT="1;URL=http://bestellen.eetsjopbaloe.com/bestelling_bevestigen.php?id='.$activatiecode.'">';
    }
}
else{
    echo "<center><p class=\"style2\">Online Bestelling plaatsen</p></center>";
    echo "<br><table align=\"center\" id=\"tabel_gegevens\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
    echo "<tr><td><b>Bestel lijst</b></td><td><b>Uitklapmenu</b></td><td><b>Bestel lijst</b></td><td><b>Uitklapmenu</b></td></tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Frites Assortiment:</td>";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap1');\">Toon/Verberg</a></td>";
    echo "<td>Snacks Assortiment:</td>";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap2');\">Toon/Verberg</a></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td>Broodjes Assortiment:</td>";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap3');\">Toon/Verberg</a></td>";
    echo "<td>Drinken Assortiment:</td>";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap4');\">Toon/Verberg</a></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Sausjes Assortiment</td>";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap5');\">Toon/Verberg</a></td>";
    echo "<td>Menu's Assortiment</td>";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap6');\">Toon/Verberg</a></td>";
    echo "</tr>";
    echo "</table><br>";
    if ($aantal != 0){
        $select = "SELECT * FROM producten_patat ORDER BY productid";
        $query = mysqli_query($con,$select);
        $aantal = mysqli_num_rows($query);
        
        echo "<table align=\"center\" id=\"uitklap1\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
        echo "<tr><td width=\"50%\"><b>Productenlijst <p class=\"style1\">Frites</p></b></td><td><b>Prijs</b></td><td><b>Aantal</b></td></tr>";

        while ($list = mysqli_fetch_object($query)){        
            echo "<tr class=\"$list->style\">
                    <td width=\"50%\">$list->omschrijving</td>
                    <td>€$list->prijs</td>
                    <td>
                        <select class=\"H1\" size=\"1\" name=\"pt["
. $list->productid . "]\">
                            "
.opties(0,21)."
                        </select></td>
                </tr>"
;
        }
    
        echo "<tr class=\"td_style_none\">";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap1');\">Klik hier</a> om dit menu weer dicht te klappen</td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "</table>";
    }

      if ($aantal != 0){
        $select = "SELECT * FROM producten_snacks ORDER BY productid";
        $query = mysqli_query($con,$select);
        $aantal = mysqli_num_rows($query);

        echo "<table align=\"center\" id=\"uitklap2\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
        echo "<tr><td width=\"50%\"><b>Productenlijst <p class=\"style1\">Snacks</p></b></td><td><b>Prijs</b></td><td><b>Aantal</b></td></tr>";

        while ($list = mysqli_fetch_object($query)){    
            echo "<tr class=\"$list->style\">
                    <td width=\"50%\">$list->omschrijving</td>
                    <td>€$list->prijs</td>
                    <td>
                        <select class=\"H1\" size=\"1\" name=\"sn["
. $list->productid . "]\">
                            "
.opties(0,21)."
                        </select></td>
                    </tr>"
;
        }
        
        echo "<tr class=\"td_style_none\">";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap2');\">Klik hier</a> om dit menu weer dicht te klappen</td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "</table>";
    }
    
    if ($aantal != 0){
        $select = "SELECT * FROM producten_broodjes ORDER BY productid";
        $query = mysqli_query($con,$select);
        $aantal = mysqli_num_rows($query);

        echo "<table align=\"center\" id=\"uitklap3\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
        echo "<tr><td width=\"50%\"><b>Productenlijst <p class=\"style1\">Broodjes</p></b></td><td><b>Prijs</b></td><td><b>Aantal</b></td></tr>";

        while ($list = mysqli_fetch_object($query)){    
            echo "<tr class=\"$list->style\">
                    <td width=\"50%\">$list->omschrijving</td>
                    <td>€$list->prijs</td>
                    <td>
                        <select class=\"H1\" size=\"1\" name=\"br["
. $list->productid . "]\">
                            "
.opties(0,21)."
                        </select>
                    </td></tr>"
;
        }
        
        echo "<tr class=\"td_style_none\">";
    echo "<td><b>Indien u een luxe broodje heeft besteld kunt u bij extra opmerkingen even aangeven om welke broodjes het gaat.<br>Bijvoorbeeld waldkorn: ham/kaas of italiaanse bol: hawaii</b></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "<tr class=\"td_style_blue\">";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap3');\">Klik hier</a> om dit menu weer dicht te klappen</td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "</table>";
        if ($aantal != 0){
        $select = "SELECT * FROM producten_drinken ORDER BY productid";
        $query = mysqli_query($con,$select);
        $aantal = mysqli_num_rows($query);
        
        echo "<table align=\"center\" id=\"uitklap4\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
        echo "<tr><td width=\"50%\"><b>Productenlijst <p class=\"style1\">Drinken</p></b></td><td><b>Prijs</b></td><td><b>Aantal</b></td></tr>";

        while ($list = mysqli_fetch_object($query)){        
            echo "<tr class=\"$list->style\">
                    <td width=\"50%\">$list->omschrijving</td>
                    <td>€$list->prijs</td>
                    <td>
                        <select class=\"H1\" size=\"1\" name=\"dr["
. $list->productid . "]\">
                            "
.opties(0,21)."
                        </select>
                    </td></tr>"
;
        }
    
        echo "<tr class=\"td_style_none\">";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap4');\">Klik hier</a> om dit menu weer dicht te klappen</td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "</table>";
        if ($aantal != 0){
        $select = "SELECT * FROM producten_sausjes ORDER BY productid";
        $query = mysqli_query($con,$select);
        $aantal = mysqli_num_rows($query);
        
        echo "<table align=\"center\" id=\"uitklap5\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
        echo "<tr><td width=\"50%\"><b>Productenlijst <p class=\"style1\">Bakjes met saus is op basis van klein<br>Als u een groot bakje wilt vul dan 2x in</p></b></td><td><b>Prijs</b></td><td><b>Aantal</b></td></tr>";

        while ($list = mysqli_fetch_object($query)){        
            echo "<tr class=\"$list->style\">
                    <td width=\"50%\">$list->omschrijving</td>
                    <td>€$list->prijs</td>
                    <td>
                        <select class=\"H1\" size=\"1\" name=\"sa["
. $list->productid . "]\">
                            "
.opties(0,21)."
                        </select>
                    </td></tr>"
;
        }

        echo "<tr class=\"td_style_none\">";
    echo "<td><b>Bakjes saus is op basis van klein.<br>Wilt u een groot bakje saus vul dan 2x in ipv 1x</b></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";    
        echo "<tr class=\"td_style_blue\">";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap5');\">Klik hier</a> om dit menu weer dicht te klappen</td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "</table>";
    }

    if ($aantal != 0){
        $select = "SELECT * FROM producten_menus ORDER BY productid";
        $query = mysqli_query($con,$select);
        $aantal = mysqli_num_rows($query);
        
        echo "<table align=\"center\" id=\"uitklap6\" width=\"90%\" cellpadding=\"10\" cellspacing=\"10\">";
        echo "<tr><td width=\"50%\"><b>Productenlijst <p class=\"style1\">Menu's</p></b></td><td><b>Prijs</b></td><td><b>Aantal</b></td></tr>";

        while ($list = mysqli_fetch_object($query)){        
            echo "<tr class=\"$list->style\">
                    <td width=\"50%\">$list->omschrijving</td>
                    <td>€$list->prijs</td>
                    <td>
                        <select class=\"H1\" size=\"1\" name=\"me["
. $list->productid . "]\">
                            "
.opties(0,21)."
                        </select>
                    </td></tr>"
;
        }

        echo "<tr class=\"td_style_none\">";
    echo "<td><b>Onze menu's worden geserveerd met een warme groente,<br>rauwkostsalade en frites.<br>Standaard wordt bij elk menu frites geserveerd.<br>Indien u gebakken aardappels wilt geef dit dan aan bij extra opmerkingen.<br><br>De nasi en bami menu's worden geserveerd met<br> kroepoek, atjar, sat�saus, warme ham en een spiegelei<br><br></b></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";    
        echo "<tr class=\"td_style_blue\">";
    echo "<td><a href=\"#\" class=\"link_11\" onclick=\"return kadabra('uitklap6');\">Klik hier</a> om dit menu weer dicht te klappen</td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "</tr>";
        echo "</table>";
    }
    }
    }

    echo "<br><br><center><p class=\"style4\">Op de toon/verberg links hierboven kunt u ons assortiment uitklappen en uw bestelling kenbaar maken<br>Nadat u dit gedaan heeft kunt u hieronder uw gegevens invullen en de bestelling uitvoeren<br><br>Als u op bestellen heeft gedrukt krijg u eerst nog een overzicht met alle gegevens en een totaalprijs.<br>Zodra u die bevestigd heeft gaat de bestelling door naar onze keuken</p><br>";
    echo "<br><table align=\"center\" id=\"tabel_gegevens\" width=\"70%\" cellpadding=\"10\" cellspacing=\"10\">";
    echo "<tr></td><td><b>Persoonlijke gegevens</b></td><td><b>Hier invullen</b></td></tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Naam:</td>";
    echo "<td><input type=\"text\" class=\"Header_zwart\" size=\"30\" name=\"naam\" /></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td>Email:</td>";
    echo "<td><input type=\"text\" class=\"Header_zwart\" size=\"30\" name=\"email\" /></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Telefoon nummer:</td>";
    echo "<td><input type=\"text\" class=\"Header_zwart\" size=\"30\" name=\"telnummer\" onkeypress=\"onlyNumeric(arguments[0])\" /></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td>Gewenste tijdstip van afhalen:</td>";
    echo "<td><select name=\"uur\" id=\"select\"><br />";
        echo besteltijd_uur(11,23);
    echo "</select>
        <select name=\"minuten\" id=\"select2\"><br />"
;
    echo "<option value=\"00\">00</option>";
    echo "<option value=\"01\">01</option>";
    echo "<option value=\"02\">02</option>";
    echo "<option value=\"03\">03</option>";
    echo "<option value=\"04\">04</option>";
    echo "<option value=\"05\">05</option>";
    echo "<option value=\"06\">06</option>";
    echo "<option value=\"07\">07</option>";
    echo "<option value=\"08\">08</option>";
    echo "<option value=\"09\">09</option>";
    echo besteltijd_min(10,60);
    echo "</select> <input type=\"button\" onClick=\"popup('http://www.bestellen.eetsjopbaloe.com/openingstijden.php','shouts','1000','1000');\" value=\"Openingstijden\"> Het is nu ";
    echo date("H:i:s", time());
    echo "</td>";
    echo "</tr>";
    echo "<tr class=\"td_style_blue\">";
    echo "<td>Extra opmerkingen:</td>";
    echo "<td><textarea class=\"tekstvak\" rows=\"6\" name=\"extra\"></textarea> <br><font color=\"#000000\"><b>* Als u een menu heeft geef dan hier aan<br>of u er frites of gebakken aardappels bij wilt<br> Een menu is een product met (Menu) erachter<br><br>* Indien u een luxe broodje heeft besteld<br>Geef dan aan welk broodje bij welk artikel hoord.<br><br>* Per bestelling komt 0,10 voor plastic<br> tasjes erbij, tenzij u hier anders aangeeft.</b></font></td>";
    echo "</tr>";
    echo "<tr class=\"td_style_none\">";
    echo "<td>Bestelling uitvoeren:</td>";
    echo "<td><input name=\"Bestellen\" type=\"submit\" class=\"H1\" value=\"Bestellen\" /></td>";
    echo "</tr>";
    echo "</form></table>";
    echo "</body>";
}

?>

  </td></tr>
    </table>
    </center>
<html>
  <script>
    window.parent.document.getElementById('iframegroot').height=document.getElementById( 'myTable' ).offsetHeight+30 ;
    window.parent.document.getElementById('iframegroot').width=document.getElementById( 'myTable' ).offsetWidth+600 ;
  </script>
<script src="scripts/awesomeiframe.js"></script>

</html>
 
PHP hulp

PHP hulp

19/04/2024 06:29:17
 
- Ariën  -
Beheerder

- Ariën -

01/04/2019 16:52:47
Quote Anchor link
Als ik zo kijk zou je code nooit gewerkt kunnen hebben:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
/* Lijn 21 */
$bestaat = mysqli_num_rows($query2);

/* Lijn 52 */

 if($bestaat == 'ja')
        {

            echo "<b>Er is een fout opgetreden</b><br><br>";
            echo "Deze bestelling is al bevestigd<br><br> <a class=\"linkje1\" href=\"javascript:history.go(-1)\">Klik hier om terug te gaan</a>";    
        }
else{
/*doet wat meer*/
}
?>


mysqli_num_rows geeft een aantal, geen string zoals 'ja'. Ik vermoed dat je in de war bent met fetch_assoc()?

Verder zie ik een hoop SQL-injection in je code, waarmee jan-en-alleman je queries zomaar kunnen aanpassen. Of zelfs jij zelfs zonder dat je het doorhebt. Jij bent zelf verantwoordelijk voor opslag van de bestellingsgegevens. Iedereen had deze kunnen opvragen! Wettelijk zijn er zelfs gevallen waarbij je dit moet melden!

Verder is die echo-put aan het eind van je script ook erg overbodig. Grote lappen HTML kan je prima buiten je PHP-blokplaatsen.
Gewijzigd op 01/04/2019 17:01:23 door - Ariën -
 
Ronnie Vos

Ronnie Vos

01/04/2019 17:36:14
Quote Anchor link
Script heeft een php programmeur veranderd naar php 7 werkte altijd wel wat dan vreemd is.
Heb zelf wel wat verstand van php niet veel dus zit al effe te googelen hoe ik dit kan oplossen.

Dat er SQL fouten in zitten is bekend daar heeft hij mij ook al voor gewaarschuwd.
 
- Ariën  -
Beheerder

- Ariën -

01/04/2019 17:47:58
Quote Anchor link
Ik vermoed dat die programmeur dan een fout heeft gemaakt. Wel frappant dat hij niet op de veiligheid let?

Gevalletje: "If you pay peanuts, you get monkeys"?

Je moet bij je van $bestaat dan controleren op het aantal. Dus > 0 (hoger dan 0)
Gewijzigd op 01/04/2019 17:48:13 door - Ariën -
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.