what is the error in this coding

Alles, was PHP betrifft, kann hier besprochen werden.

what is the error in this coding

Postby cboys00 » 28. February 2018 03:51

1 <?php
2 include("pengesahan.php"); //untuk keselamatan capaian pada laman ini
3 require('config.php'); //untuk sambungan pada p.data
4
5 if (isset($_POST["penerbit"]))
6 {
7 $penerbit=$_POST["penerbit"];
8 $data1=mysqli_query($sambung,"INSERT into penerbit(penerbit) values
9 ('$penerbit')")or die(mysqli_error());
10
11 //makluman pada pendaftar
12 echo "<script>alert('Penerbit baru direkodkan');
13 window.location='daftar_penerbit.php'</script>";
14 }
15 else
16 {
17 ?>
18
19 <html>
20 <head>
21 <tittle>PENERBIT BUKU</tittle>
22 </head>
23 <CENTER>
24 <h3>DAFTAR PENERBIT BARU</h3>
25
26 <!-- daftar penerbit baru-->
27 <form name="form1" action="daftar_penerbit.php" method="POST">
28 <fieldset>
29 <label>Penerbit: </label><input type="text" name="penerbit" values="" />
30 <input type="submit" value="Tambah" name="Tabah"
31 </fieldset>
32 <form>
33 <h3>SENARAI PENERBIT BERDAFTAR</h3>
34 <table width="350" border="1" align="center">
35 <tr>
36 <td width="40"><b>Bil.</b></td>
37 <td width="120"><b>Penerbit</b></td>
38 <td width="100"><b>Kemaskini</b></td>
39 <td width="100"><b>Hapus</b></td>
40 </tr>
41
42 <!-- senaraikan penerbit dari p.data-->
43 <?php
44 $data1=mysqli_query($sambung,"select * from penerbit");
45 $no=1;
46 while ($info1=mysqli_fecth_array($data1))
47 {
48 ?>
49
50 <tr>
51 <td><?php echo $no; ?></td>
52 <td><?php echo $info1['penerbit']; ?></td>
53 <td><a href="kemaskini_penerbit .php?idpenerbit=<?php echo $info1['idpenerbit'];
54 ?>">Kemaskini</a></td>
55 <td><a href="hapus_penerbit.php?idpenerbit=<?php echo $info1['idpenerbit'];
56 ?>">Hapus</a></td>
57 </tr>
58
59 <!-- bilangan rekod-->
60 <?php
61 $no++;
62 }
63 ?>
64
65 </table><br>
66 <inputtype="buttton" value="Tutup Tertingkap Ini" onclick="self.close()">
67 </center>
68 <?php}?>
69 </body>
70 </html>

error:

Line 5
Line 7

“Do not Access Superglobal$_POST Array Directly
Use some filterering functions instead(e.g.filter_input(),conditions with is_’0
Functions, etc.).”



Line 70
“syntax error
Unexpected: End of file
Expected: exit,if,integer”



how to solve???
cboys00
 
Posts: 23
Joined: 15. January 2018 02:27
XAMPP version: 3.2.2
Operating System: 7

Re: what is the error in this coding

Postby Nobbie » 28. February 2018 13:46

Debug your code, what else?

Line 5, Line 7 seems to be a hint from Netbeans(?) (this is NOT a netbeans forum), its only a warning. Its on you to follow that advice or not.

Linie 70: on the first look it seems there is missing a closing bracket } (from the very first else-statement in the code).

This hint is my only and last hint, this forum is not a giant debugger. You have to debug your code by yourself. The code is quite ugly and difficult to read - i would not code that way.
Nobbie
 
Posts: 13165
Joined: 09. March 2008 13:04


Return to PHP

Who is online

Users browsing this forum: No registered users and 46 guests