questa è tutta la pagina agg_prod.php che viene chiamata dal form quando inserisco un prodotto
Codice PHP:
<?php
session_start();
$con=mysql_connect(...........);
if(!$con){
die('Impossibile connettersi a: ' . mysql_error());
}
mysql_select_db(..............);
$id=$_POST['id'];
$nome=$_POST['nome'];
$prezzo=$_POST['prezzo'];
$nome=mysql_real_escape_string($nome);
$prezzo=mysql_real_escape_string($prezzo);
$id_sessione=$_POST['id'];
$nome_sessione=$_POST['nome'];
$prezzo_sessione=$_POST['prezzo'];
$sql="INSERT INTO prodotto (id, nome, prezzo, descrizione) VALUES ('$id','$nome','$prezzo', '".addslashes($_POST[descrizione])."')";
$_SESSION['id']=$id_sessione;
$_SESSION['nome']=$nome_sessione;
$_SESSION['prezzo']=$prezzo_sessione;
if (isset($_POST['upload_pdf'])){
$pdfDirectory = "prodotti/";
$filename=$_FILES['filepdf']['name'];
$filename=$nome;
$filename = basename( $filename, ".jpg");
$filename = preg_replace("/[^A-Za-z0-9_-]/", " ", $filename).".jpg";
if(move_uploaded_file($_FILES['filepdf']['tmp_name'], $pdfDirectory.$filename)) {
$pdfWithPath = $pdfDirectory.$filename;
}
}
$descrizione=nl2br($_POST[descrizione]);
$fp=fopen('prodotti/'.$nome.'.php','w');
fwrite($fp,
"<?php
session_start();
?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>La Serenissima - Scheda prodotto</title>
<link rel=\"shortcut icon\" href=\"/images/logo_short.PNG\" type=\"image/x-icon\" />
<link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\" />
</head>
<body class=\"corpo\">
<div id=\"container\">
<div id=\"header\">
<img src=\"/images/logo.PNG\" alt=\"La Serenissima\" style=\"width:303;height:293;margin-top:20px;margin-bottom:10px;\" />
</div>
<div id=\"tmenu\">
<ul id=\"topmenu\">[*]<a href=\"/index.php\">HOME</a>[*]<a id=\"click\" href=\"/prodotti.php\">PRODOTTI</a>[*]<a href=\"/eventi.php\">EVENTI</a>[*]<a href=\"/chisiamo.php\">CHI SIAMO</a>[*]<a href=\"/contatti.php\">CONTATTI</a>[/list]
</div>
<div id=\"main\">
<div>
<h3>Scheda prodotto</h3>
<u>$nome</u>
</div>
<a href=\"/prodotti.php\">Torna ai Prodotti</a>
  [b]|[/b]  <a href=\"/agg_carrello.php?id=$id_sessione\">Aggiungi al carrello</a>
</p>
Prezzo equivalente ad una quantità: $prezzo €
<a href=\"/$pdfWithPath\" target=\"_blank\"><img style=\"clear:both;float:right;margin-bottom:20px;border:2px solid #c9c9fb;\" src=\"/$pdfWithPath\" title=\"fare click per ingrandire\" width=\"220\" height=\"320\" /></a>$descrizione
</p>
</div>
<div id=\"footer\">
<a href=\"/admin.php\">[b]Amministrazione[/b]</a> | [b]Powered by[/b] <a href=\"http://francescopassanante.eu\" target=\"_blank\">Francesco Passanante</a></p>
</div>
</div>
</body>");
fclose($fp);
if(!mysql_query($sql,$con)){
die('Errore: ' . mysql_error());
}
mysql_close($con);
header("Location:/prodotti.php");
?>
l'sql che avevo eseguito per selezionare i prodotti l'ho tolta perchè la reputavo inutile tanto i valori dovrebbero passare ugualmente