<?
include("dblib.inc");
include("clublib.inc");
checkAdmin();
$message = "";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Inserimento Articoli</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body bgcolor="#FFFFFF" link="#504C43" alink="#000000" vlink="#504C43" text="#000000">
<?
include("Header.php");
include 'db.php';
// Define post fields into simple variables
$imgpicc = $_POST['imgpicc'];
$imggra = $_POST['imggra'];
$oggnom = $_POST['oggnom'];
$prezog = $_POST['prezog'];
$periva = $_POST['periva'];
$descrogg = $_POST['descrogg'];
/* Lets strip some slashes in case the user entered
any escaped characters. */
$imgpicc = stripslashes($imgpicc);
$imggra = stripslashes($imggra);
$oggnom = stripslashes($oggnom);
$prezog = stripslashes($prezog);
$periva = stripslashes($periva);
$descrogg = stripslashes($descrogg);
/* Do some error checking on the form posted fields */
if((!$imgpicc) || (!$imggra) || (!$oggnom) || (!$quant) || (!$prezog) || (!$periva) || (!$descrogg)){
echo 'Non hai inserito le seguenti info obbligatorie! <br />';
if(!$imgpicc){
echo "Immagine piccola obbligatoria. Inserire, Grazie.<br />";
}
if(!$imggra){
echo "Immagine popup obbligatoria. Inserire, Grazie. <br />";
}
if(!$oggnom){
echo "Nome Articolo obbligatorio. Inserire, Grazie.<br />";
}
if(!$quant){
echo "Quantità magazzino obbligatoria. Inserire, Grazie.<br />";
}
if(!$prezog){
echo "Prezzo obbligatorio. Inserire, Grazie.<br />";
}
if(!$periva){
echo "Iva obbligatoria. Inserire, Grazie.<br />";
}
if(!$descrogg){
echo "Descrizione obbligatoria. Inserire, Grazie.<br />";
}
// Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
echo "<p><a href=tabcatalg.php>Torna Indietro</a></p>";
exit(); // if the error checking has failed, we'll exit the script!
}
if(($email_check > 0) || ($username_check > 0)){
echo "Per favore correggere i seguenti errori: <br />";
if($email_check > 0){
echo "<strong>Oggetto già inserito o nome già in uso !<br />";
unset($oggnom);
}
echo "<p><a href=tabcatalg.php>Torna Indietro</a></p>";
// Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
/* Random Password generator.
http://www.phpfreaks.com/quickcode/Random_Password_Generator/56.php
We'll generate a random password for the
user and encrypt it, email it and then enter it into the db.
*/
// Enter info into the Database.
$info2 = htmlspecialchars($info);
$query = 'CREATE TABLE IF NOT EXISTS '.$catalog.' ('
. ' `idart` varchar(13) NOT NULL, '
. ' `quant` int(6) NOT NULL default \'0\', '
. ' `imgpicc` varchar(100) NOT NULL, '
. ' `imggra` varchar(100) NOT NULL, '
. ' `oggnom` varchar(60) NOT NULL, '
. ' `prezog` decimal(10,2) NOT NULL default \'0.00\', '
. ' `periva` int(2) NOT NULL default \'0\', '
. ' `descrogg` longtext NOT NULL, '
. ' KEY `idart` (`idart`))';
$result = mysql_db_query("$database_name", $query);
$sql = mysql_query("INSERT INTO ".$catalog." (idart,imgpicc, imggra, oggnom, quant, prezog, periva, descrogg)
VALUES('$idart','$imgpicc', '$imggra', '$oggnom', '$quant', '$prezog', '$periva', '$descrogg')") or die (mysql_error());
if(!$sql){
echo 'Si è verificato un errore .Contattate il Webmaster.';
} else {
echo "Articolo inserito correttamente, clicca<a href=Admin_tabcatalg.php> QUI</a> per inserire un nuovo Articolo";
}
?>
</body>
</html>