Salve a tutti, sono nuovo del forum quindi spero di scrivere giusto. sto seguendo un tutorial per la realizzazione di un sito e-commerce e sono bloccato sulla pagina per aggiungere un nuovo prodotto, in quanto il form non fa reazione quando premo il bottone, anzi sembra di premere il tasto reset, nuovi prodotti non vengono registrati, e quello che avevo scritto prima si cancellaperchè?? spero qualcuno possa aiutarmi
![]()
codice:
<?php
session_start();
if(!isset($_SESSION["manager"])){
header("location: admin_login.php");
exit();
}
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]);
$manager = preg_replace('#[^A_Za-z0-9]#i','',$_SESSION["manager"]);
$password = preg_replace('#[^A_Za-z0-9]#i','',$_SESSION["password"]);
include"../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM admin WHERE username='$manager' AND password='$password' LIMIT 1");
$existCount = mysql_num_rows($sql);
if($existCount == 0) {
echo("I tuoi dati non sono registrati nel Database");
exit();
}
?>
<?php
error_reporting(E_ALL);
ini_set('display_errors','1')
?>
<?php
if(isset($_POST['prduct_name'])) {
$product_name = mysql_real_escape_string($_POST['product_name']);
$price = mysql_real_escape_string($_POST['price']);
$category = mysql_real_escape_string($_POST['category']);
$subcategory = mysql_real_escape_string($_POST['subcategory']);
$details = mysql_real_escape_string($_POST['details']);
$sql = mysql_query("SELECT id FROM products WHERE product_name='$product_name' LIMIT 1");
$productMatch = mysql_num_rows($sql);
if($productMatch > 0) {
echo 'Spiacente ma hai già inserito questo articolo nel sistema, clicca qui';
exit();
}
$sql = mysql_query("INSERT INTO products(product_name,price,details,category,subca tegory,date_added) VALUES('$product_name','$price','$details','$categ ory','$subcategory',now())") or die(mysql_error());
$pid = mysql_insert_id();
$newname="pid.jpg";
move_uploaded_file($_FILES['fileField']['tmp_name'],"../inventory_images/$newname");
header("location:inventory_list.php");
exit();
}
?>
<?php
//This block grabs the whole list for viewing
$product_list ="";
$sql=mysql_query("SELECT * FROM products ORDER BY date_added DESC");
$productCount=mysql_num_rows($sql);//count the output amount
if($productCount>0){
while($row=mysql_fetch_array($sql)){
$id = $row["id"];
$product_name=$row["product_name"];
$date_added=strftime("%b%d,%Y",strtotime($row["date_added"]));
$product_list.="$date_added - $id - $product_name Modifica|Elimina
";
}
}else{
$product_list = "Non hai inserito nessun prodotto";
}
?>
<?php
//Delete Item Question to Admin and delete product if they choose
if (isset($_GET['deleteid'])) {
echo 'Do you really want to delete product with id of '.$_GET['deleteid'].' ? Yes | No';
exit();
}
if (isset($_GET['yesdelete'])) {
// Remove from folder and system
$id_to_delete = $_GET['yesdelete'];
$sql = mysql_query("DELETE FROM products WHERE id='$id_to_delete' LIMIT 1") or die (mysql_error());
$filetodelete = ("../invetory_images/$id_to_delete");
if (file_exists($filetodelete)) {
unlink($filetodelete);
}
header("location: inventory_list.php");
exit();
}
?>
<?php
//Error Reporting
error_reporting(E_ALL);
ini_set('display_errors','1');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Amminstra Inventario</title>
<link rel="stylesheet" href="../style/style.css" type="text/css" media="screen" />
</head>
<body>
<div align="center"id="mainWrapper">
<?php
include_once("../template_header.php");
?>
<div id="pageContent">
<div align="right" style="margin-right: 32px">
+ Aggiungi Nuovo Prodotto</div>
<div align="left" style="margin-left: 24px;">
<h2>Amministra l'inventario - lista</h2>
<?php echo $product_list; ?></p>
</p>
</div>
</p>
<h3 align="center">Aggiungi Un Nuovo Prodotto</h3>
</p>
<a name="inventoryForm" id="inventoryForm"></a>
<form action="inventory_list.php" enctype="multipart/form-data" name="MyForm" id="MyForm" method="post">
<table align="center" width="826" border="0">
<tr>
<td height="40" width="195">Nome del Prodotto</td>
<td width="621"><label><input type="text" name="product_name" id="product_name" size="64"/></label></td>
</tr>
<tr>
<td height="40" width="195">Prezzo del Prodotto</td>
<td width="621">€ <label><input type="text" name="price" id="price" size="15"/></label></td>
</tr>
<tr>
<td height="40" width="195">Categoria</td>
<td width="621">
<label>
<select name="category" id="category">
<option value=""></option>
<option value="Abbigliamento">Abbigliamento</option>
<option value="Elettronica">Elettronica</option>
</select>
</label>
</td>
</tr>
<tr>
<td height="40" width="195">Sottocategoria</td>
<td width="621">
<label>
<select name="subcategory" id="subcategory">
<option value=""></option>
<option value="Cappelli">Cappelli</option>
<option value="Pantaloni">Pantaloni</option>
<option value="Maglie">Maglie</option>
</select>
</label>
</td>
</tr>
<tr>
<td height="40" width="195">Dettagli Prodotto</td>
<td width="621"><label><textarea name="details" id="details" cols="64" rows="5"></textarea></label></td>
</tr>
<tr>
<td height="40" width="195">Immagine del Prodotto</td>
<td width="621"><label><input type="file" name="fileField" id="fileField"></label></td>
</tr>
<tr>
<td height="40" width="195"></td>
<td width="621"><label><input type="submit" name="button" id="button" value="Aggiungi il Prodotto"/></label></td>
</tr>
</table>
</form>
</div>
<?php
include_once("../template_footer.php");
?>
</div>
</body>
</html>

perchè?? spero qualcuno possa aiutarmi
Rispondi quotando
