Salve a tutti!
Ho seguito tutte le lezioni di php e di sql...e ho imparato tantissimo. Però devo realizzare un progetto che per me è troppo difficile.... qualcuno può seguirmi?
Devo realizzare una piccola interfaccia con cui attraverso una form si possa aggiornare il database di progetti (commesse) di una azienda.
Nel database intranet ho le seguenti tabelle e campi:
[table][tr]
[td]
Backup >IdBackup >IdCliente >NomeCommessa >IdTipoCommessa >IdTipoBackup >Data >Keywords
[/td]
[td] [/td]
[td]
Cliente >IdCliente >NomeCliente
[/td]
[td] [/td]
[td]
TipoBackup >IdTipoBackup >NomeBackup[/td]
[td] [/td]
[td]
TipoCommessa >IdTipoCommessa >TipoCommessa[/td][/tr]
[tr][td]Backup riunisce tutte le info
relative ad ogni progetto che
devono essere pescate dalle
altre tabelle[/td][td][/td][td]Qui vanno i dati sui clienti[/td][td][/td][td]TipoBackup=se è su
cd/dvd/mini-dv....etc
I nomi saranno gli elementi
della tabella[/td][td][/td][td]TipoCommessa= se il progetto
è un gioco, un sito web,
un cd-rom...[/td][/tr][/table]
A questo punto vi posto il codice che sono riuscita a fare...
codice della form
<?php
require "config.php";
require "connect.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aggiungi</title>
<style>
body{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;}
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="report.php">
<table width="500px" border="0" align="center" cellpadding="5">
<caption>
<strong>Aggiungi una nuova commessa</strong>
</caption>
<tr>
<td width="137">Nome commessa</td>
<td width="197">
<input type="text" name="nome_commessa" id="nome_commessa" value="" /> </td>
<td width="197"> </td>
</tr>
<tr>
<td>Cliente</td>
<td>
<select name="nome_cliente" id="nome_cliente">
<?php
$ricevuta = mysql_query("SELECT IdCliente, NomeCliente FROM Cliente");
while ($row = mysql_fetch_assoc($ricevuta))
{
?>
<option value="<?php echo $row['IdCliente']; ?>"><?php echo $row['NomeCliente']; ?></option>
<?php
}
?>
</select>
</td>
<td><a href="#">aggiungi cliente</a></td>
</tr>
<tr>
<td>Data</td>
<td><input type="text" name="data" id="data" value="<?php echo date ("d/m/y"); ?>"/> </td>
<td> </td>
</tr>
<tr>
<td>Tipo commessa</td>
<td>
</td>
<td><a href="#">aggiungi tipo commessa</a></td>
</tr>
<tr>
<td>Tipo backup</td>
<td><select name="tipo_backup" id="tipo_backup">
</select></td>
<td><a href="#">aggiungi tipo backup</a></td>
</tr>
<tr>
<td>Numero</td>
<td><input type="text" name="numero" id="numero" /></td>
<td> </td>
</tr>
<tr>
<td valign="top">Keywords</td>
<td><label>
<textarea name="keywords" id="keywords" cols="30" rows="5"></textarea>
</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="aggiungi" id="aggiungi" value="Aggiungi commessa" />
</label></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
codice pagina report.php
<?php
require "config.php";
require "connect.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>report</title>
</head>
<body>
<br>
<?php
$id_cliente = $_POST['id_cliente'];
$nome_cliente = $_POST['nome_cliente'];
$query = "INSERT INTO Backup (IdCliente)
VALUES ('$id_cliente')";
// invio la query
$result = mysql_query($query);
// controllo l'esito
if (!$result) {
die("Errore nella query $query: " . mysql_error());
}
?>
<br>
</body>
</html>
.....già qui da un errore che non capisco.
Potete aiutarmi???
grazie