<?php
include 'conf.php';
session_start();
if ($_SESSION['username']==$usern) ;
else{
header("Location: login.htm");
}
{ ?>
<html>
<head>
<title>Modulo di inserimento nuovo oggetto</title>
</head>
<?php
include 'body.php';
?>
<table align='center' bgcolor='yellow' border='1' height='' width='900' cellpadding='0' cellspacing='0'>
<p align="center"><font color="black" size="5"><b>Inserisci un nuovo oggetto</b></font>
<form action='oggetti.php?reg=1' method='POST'>
<tr>
<td align='center' width=''><b>Descrizione</b></td>
<td align='center' width=''><b>Prezzo</b></td>
<td align='center' width=''><b>Quantita'</b></td>
<td align='center' width=''><b>%</b></td>
<td align='center' width=''><b>Codice venditore</b></td>
<td align='center' width=''><b>Stato</b></td>
<td align='center' width=''><b>Nome immagine</b></td>
<td align='center' width=''><b>Moltiplica record</b></td>
<td align='center' width=''><b></b></td>
</tr>
<td align='center'width=''><input type='text' name='descrizione'></td>
<td align='center'width=''><input type='text' name='prezzo'></td>
<td align='center'width=''><input type='text' name='quantita'></td>
<td align='center' width=''><input type='text' name='percento'></td>
<td align='center' width=''><input type='text' name='id_venditore'></td>
<td align='center' width=''><input type='text' name='venduto' value="in vendita" readonly="readonly"></td>
<td align='center' width=''><input type='text' name='link'></td>
<td align='center' width=''><input type='text' name='nvolte' value='1' size='4'></td>
<td align='center' width=''><input type='submit' name='procedi' value='Procedi'></td><br>
</form></font></p>
</table><br>
<?
include_once ("config.php");
include_once ("connect.php");
if (isset($_POST['procedi']) && $_POST['procedi'] == "Procedi") {
if ((int) $_POST['nvolte'] < 10) {
$reg = $_GET['reg'];
if ( $reg == 1 ) {
$id = $_POST['id'];
$data = date('d/m/y');
$descrizione = $_POST['descrizione'];
$prezzo = $_POST['prezzo'];
$quantita = $_POST['quantita'];
$percento = $_POST['percento'];
$provvigione = ($prezzo*$quantita) *$percento/100;
$rimborso = ($prezzo*$quantita) - $provvigione;
$id_venditore = $_POST['id_venditore'];
$venduto = $_POST['venduto'];
$data_vendita = $_POST['data_vendita'];
$link = $_POST['link'];
for($i=0; $i < $_POST['nvolte']; $i++) {
mysql_query("INSERT INTO oggetti
( id , data , descrizione , prezzo , quantita , percento , provvigione , rimborso , id_venditore , venduto , data_vendita , link )
VALUES
( '$id' , '$data' , '$descrizione', '$prezzo', '$quantita', '$percento', '$provvigione', '$rimborso', '$id_venditore', '$venduto', '$data_vendita', 'link/$link' )") OR DIE(mysql_error());
}
}
} else { echo "<p>Limite massimo di 10 oggetti superato</p>";
}
while ($row = mysql_fetch_array( $result )) {
$id=$row['id'];
$result = mysql_query ("SELECT * FROM oggetti WHERE data > 31/10/12");
}
echo "<td align='center'> $id </td> <td align='center'> $data </td> <td align='center'> $descrizione </td>";
}
?>
</body>
</html>
<? } ?>