1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
if (isset($_POST['valide']))
{
$id=$_POST['id'];
// Si le fichier a été téléchargé avec succès, j'affiche un message de confirmation
if(move_uploaded_file($_FILES["userfile"]["tmp_name"],$stock.$_FILES["userfile"]["name"]))
{echo htmlspecialchars("Le fichier".$_FILES["userfile"]["name"]." a ÈtÈ tÈlÈchargÈ avec succËs"); echo "<br><br><br>";}
else echo htmlspecialchars( "Une erreur est survenue lors du chargement du fichier." );
// Je récupère les informations de la location ou je stoppe les traitements en cas d'erreur
echo $req1="SELECT location.* FROM location WHERE id=$id";
echo "<br>test<br>";
$sql = mysql_query($req1) or die( mysql_error() );
// :S euh... Áa te sert ‡ quoi, Áa... ‡ afficher? ou est-ce un debug?
$voir = mysql_fetch_assoc( $sql ) . "<br />";
// Je rÈcupËre toutes les photos rattachÈes ‡ la location
$sql_fich = "SELECT `url_photo` FROM `location` WHERE `id` = $id";
$result = mysql_query($sql_fich);
$result = mysql_result($result,0);
// Je dÈtermine le chemin du fichier ‡ supprimer
$fich_a_suppr = "../images/photos_location/".$result;
unlink( $fich_a_suppr );
$req2="UPDATE `location` SET `titre` ='".$_POST["titre"]."', `ligne1`='". $_POST["ligne1"]."', `ligne2`='".$_POST["ligne2"]."', `ligne3`='".$_POST["ligne3"]."', `ligne4`= '" . $_POST[ "ligne4" ] . "', `ligne5` = '" . $_POST[ "ligne5" ] . "', `url_photo` = '" . $_FILES[ "userfile" ][ "name" ] . "' WHERE `id` = $id";
echo $req2;
$sql = mysql_query($req) or die( mysql_error() );
echo $sql;
$sql = mysql_query( "SELECT * FROM `location`" ) or die( mysql_error() );
$voir = mysql_fetch_assoc( $sql ) . "<br />\n";
// Si aucune identifiant n'a ÈtÈ spÈcifiÈ, j'envoie un message d'erreur
}
?>
Voici le produit du location id=<? echo $id; ?> actuel :<br />
<?
$sql0 = mysql_query( "SELECT location.* FROM location WHERE id = $id" ) or die( mysql_error() );
$voir=mysql_fetch_array($sql0);
echo "Titre: " . $voir[ "titre" ] . "<br />\n";
echo "<img src='http://www.agentimmobiliersilvaindamiani.com/images/photos_location/".$voir['url_photo']."' width=280 height=180>";
echo "<br>";
for ($i=1;$i<=5;$i++) echo "Ligne".$i.":".$voir['ligne'.$i]."<br>";
?>
<br><br>
<form method="post" action="modif_loc2.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<? echo $_GET['id'] ?>">
Remplacer par:
<br>
Titre: <input type=text name="titre" size="55" value="<? echo $voir['titre'] ?>">
<br>
<?
for ($i=1;$i<=5;$i++)
{
echo "ligne".$i;
echo ": <input type=text name='ligne".$i."' size=55 value='";
echo htmlspecialchars($voir['ligne'.$i],ENT_QUOTES);
echo "'><br>";
}
?>
<input type="hidden" name="MAX_FILE_SIZE" value="4000000">
<input type="file" name="userfile">
<input type="submit" value="Mettre à jour" name="valide"> |