ho questo form per inserire dei dati + un'immagine nel database.. ma al momento dell'invio mi dice "could not connect."
eppure è tutto corretto!
come mai?
<?php
include('function/config.inc');
session_start();
$flag = $_POST['flag'];
$nome = $_POST['nome'];
$descrizione = $_POST['descrizione'];
if (is_uploaded_file($_FILES['foto']['tmp_name'])) {
$foto = "/var.../".$_FILES['foto']['name']; //('/var.../immagine.jpg')
move_uploaded_file($_FILES['foto']['tmp_name'],$foto);
}
else { $foto = ""; }
if ($flag == 99) {
$query="INSERT INTO jobs (nome,descrizione,foto) VALUES ('$nome','$descrizione','$foto')";
// echo "QUERY INSERIMENTO: ".$query;
mysql_query($query,$connessione) or die('Could not connect:' .mysql_error());
echo "inserimento avvenuto con successo!";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Inserisci app!</title>
</head>
<body>
<center>
<h1>Inserisci app!</h1>
<form action="inserisci_app.php" method="post" style="border: medium solid red;"class="modulo" enctype="multipart/form-data">
<input type="hidden" name="flag" value="99">
<table border="0" cellspacing="5" cellpadding="6" width="350">
<tr>
<td width="150">Nome:</td>
<td width="200"><input type="text" name="nome"></td>
</tr>
<tr>
<td width="150">Descrizione:</td>
<td width="200"><input type="text" name="descrizione"></td>
</tr>
<tr>
<td width="150">Foto:</td>
<td width="200"><input type="file" name="foto"></td>
</tr>
<tr>
<td width="150"><input type="reset" value="Svuota Modulo"></td>
<td width="200"><input type="submit" name="submit" value="Inserisci"></td>
</tr>
</table>
</form>
</center>
</body>
<?php
mysql_close($connessione);
?>
</html>