Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone, I'm new, I'm doing a school project on creating a web portal that manages shipments via code
i created both the database and the php and html code. At the time of printing the table where it tells me the tracking of the package does not come out
no result but only the written code (attached the screenshot of the error), I also leave you the code folder, thanks
Guys I don't know if I can load the xammp database


What I have tried:

<pre>PHP:
<html>
<head>
<title>Esempio traccia 2018</title>
</head>
<body>
<?
include("connessione.php");
$NomeDB="fast_delivery5";
connetti_db($NomeDB,$con);
$spedizione=$_POST['spedizione'];
$query = "SELECT sedi.codice as cod,sedi.nome as nome, data_orario FROM transiti, sedi WHERE transiti.cod_spedizione= '".$spedizione."' and sedi.codice=transiti.cod_sede";
$result = $conn->query($query);
$i = 0;
if ($result->num_rows > 0) {
echo "<table border=\"1\">";
echo "<tr><td bgcolor=\"#FFFFFF\">Codice Sede</td><td bgcolor=\"#FFFFFF\">Città</td>";
echo "<td bgcolor=\"#FFFFFF\">Ora</td></tr>";

while($row = $result->fetch_assoc()) {
if($i % 2 == 0){
echo "<tr><td bgcolor=\"#BBBBBB\"> ".$row['cod'];
echo "</td><td bgcolor=\"#BBBBBB\"> ".$row['nome'];
echo "</td><td bgcolor=\"#BBBBBB\"> ".$row['data_orario']."</td></tr>";
}
else{
echo "<tr><td bgcolor=\"#DDDDDD\"> ".$row['cod'];
echo "</td><td bgcolor=\"#DDDDDD\"> ".$row['nome'];
echo "</td><td bgcolor=\"#DDDDDD\"> ".$row['data_orario']."</td></tr>";
}
$i++;
}
} else {
echo "0 results";
}
echo "</table>";
$conn->close();
?>
</body>
</html>




HTML (barra di ricerca)

<html>
<head>
Ricerca spedizione
</head>

<body>
<form action="2018.php" method="POST" name="form">

<label for="spedizione">Id Spedizione</label>
<input id="spedizione" name="spedizione" type="text" size="30"> <br> <br>

<input type="submit" value="ricerca"> <br>
</form>
</body>
</html>
Posted
Updated 25-May-21 4:12am
Comments
Richard Deeming 21-May-21 6:06am    
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
PHP: SQL Injection - Manual[^]

1 solution

I see your connection:
connetti_db($NomeDB,$con);
but do not see where you define $con before using it in the function.

Now I had no success looking up you function connetti_db() - perhaps an Italian version of php? Try this link [^] for some help in creating the connection.

Only a best guess since I didn't see the error you said you attached (you really need to cut/paste strings for Q&A input).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900