Communauté Informatique NDFR.net : Aide à la création d'une console d'administration - Programmation Web (HTML, PHP, ASP, Java, XML, etc.)
 
Aide à la création d'une console d'administration
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 17-07-2006, 18:18
wuub's Avatar
wuub wuub is offline
Membre senior
 
Join Date: 13-11-2002
Location: Montpellier
Age: 50
Posts: 552
Send a message via MSN to wuub
Rebonjour,
j'ai pas mal avancé mine de rien ^^
Je me trouve ceci dit face un soucis c'est que je ne parviens pas à mettre le nom de l'image uploadée dans la base de données.

Une ame charitable aurait elle le temps d'y jeter un oeil ?
D'avance mille mercis

PHP Code:
<?php
    
require_once '../secure/dbconnect.php';

    if(isset(
$_FILES['photo']))
    {
      
// params
      
unset($erreur);
      
$extensions_ok = array('png''gif''jpg''jpeg');
      
$taille_max 100000;
      
$dest_dossier '/tmp/';
      
// vérifications
      
if( !in_arraysubstr(strrchr($_FILES['photo']['name'], '.'), 1), $extensions_ok ) )
      {
        
$erreur 'Veuillez sélectionner un fichier de type png, gif ou jpg !';
      }
      elseif( 
file_exists($_FILES['photo']['tmp_name'])
              and 
filesize($_FILES['photo']['tmp_name']) > $taille_max)
      {
        
$erreur 'Votre fichier doit faire moins de 500Ko !';
      }
      
// copie du fichier
      
if(!isset($erreur))
      {
        
$dest_fichier basename($_FILES['photo']['name']);
        
// formatage nom fichier
        // enlever les accents
        
$dest_fichier strtr($dest_fichier'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ''AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
        
// remplacer les caracteres autres que lettres, chiffres et point par _
        
$dest_fichier preg_replace('/([^.a-z0-1]+)/i''_'$dest_fichier);
        
// copie du fichier
        
move_uploaded_file($_FILES['photo']['tmp_name'], $dest_dossier $dest_fichier);
      }
    }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <link rel="stylesheet" href="piergest_admin.css" type="text/css">
    </head>
    
  <body bgcolor=black text=white>
    <table cellpadding=0 cellspacing=0 width=700 height=40 border=1 align=center class=frame>
        <tr>
            <td align=center bgcolor=#660000><b>Console d'administration des LOCATIONS piergest & patrimoine</b></td>
        </tr>
    </table>
    <br>
    <table cellpadding=0 cellspacing=0 width=700 height=20 border=0 align=center class=frame>
        <tr>
            <td align=center>
                <b>Autres liens :</b>
                <a href="ventes_admin.php">Gestion des ventes</a>
                - <a href="promo_admin.php">Gestion de la promo</a>
            </td>
        </tr>
    </table>
    <table cellpadding=0 cellspacing=0 width=700 height=40 border=0 align=center class=frame>
        <tr>
            <td bgcolor=#000000>
<?php
    
if(isset($erreur)){
      echo 
'<p>'$erreur ,'</p>';
    }

    if(isset(
$_POST['send'])) {
        if(
$_POST['send'] == 'new') {
        
$sql =
        
"INSERT INTO locations
            (
             loc_ref
            ,loc_type
            ,loc_surface
            ,loc_loggia
            ,loc_loyer
            ,loc_charges
            ,loc_frais
            ,loc_lieu
            ,loc_dispo
            ,loc_image
            ,loc_details
            )

        VALUES
               (

             '"
.$_POST['loc_ref']."'
            ,'"
.$_POST['loc_type']."'
            ,'"
.$_POST['loc_surface']."'
            ,'"
.$_POST['loc_loggia']."'
            ,'"
.$_POST['loc_loyer']."'
            ,'"
.$_POST['loc_charges']."'
            ,'"
.$_POST['loc_frais']."'
            ,'"
.$_POST['loc_lieu']."'
            ,'"
.$_POST['loc_dispo']."'
            ,'"
.$_POST['loc_image']."'
            ,'"
.$_POST['loc_details']."'
            )"
;

        }
        elseif(
$_POST['send'] == 'update') {
        
$sql =
            
' UPDATE locations SET
              loc_ref = "'        
.$_POST['loc_ref'].'"
            , loc_type = "'        
.$_POST['loc_type'].'"
            , loc_surface = "'    
.$_POST['loc_surface'].'"
            , loc_loggia = "'    
.$_POST['loc_loggia'].'"
            , loc_loyer = "'    
.$_POST['loc_loyer'].'"
            , loc_charges = "'    
.$_POST['loc_charges'].'"
            , loc_frais = "'    
.$_POST['loc_frais'].'"
            , loc_lieu = "'        
.$_POST['loc_lieu'].'"
            , loc_dispo = "'    
.$_POST['loc_dispo'].'"
            , loc_image = "'    
.$_POST['loc_image'].'"
            , loc_details = "'    
.$_POST['loc_details'].'"
            WHERE loc_id = "'    
.$_POST['loc_id'].'"';
        }
        
mysql_query($sql,$db_link) or die(mysql_error());
    }
    if(isset(
$_GET['delete']) and is_numeric($_GET['delete'])) {
       
mysql_query("DELETE FROM locations WHERE loc_id = \"".$_GET['delete']."\"",$db_link);
       
header("location: loc_admin.php");
    }
    if(isset(
$_GET['edit']) and is_numeric($_GET['edit'])) {
        
$Id $_GET['edit'] ;
        
$sql 'SELECT * FROM locations WHERE loc_id = "'.$Id.'" LIMIT 1' ;
        
$rc mysql_query($sql,$db_link);
        while(
$loc_data mysql_fetch_array($rc)) {

    
// Modification d'une location
            
print '
            <fieldset>
            <legend>Modification d\'une location référence : '
.$loc_data['loc_ref'].'</legend>
            <form action="loc_admin.php" method="post" name="loc_edit" enctype="multipart/form-data">
            <table>
                <tr><td width=100>Référence    </td><td> &laquo; <input class="text" type="text" name="loc_ref"    size="10" value="'
.htmlentities($loc_data['loc_ref']).'"> &raquo; Code de référence correspondant à votre logiciel de gestion</td></tr>
                <tr><td><b>Localisation</b>    </td><td> &laquo; <input class="text" type="text" name="loc_lieu"     size="10" value="'
.htmlentities($loc_data['loc_lieu']).'"> &raquo; Emplacement géographique de la location</td></tr>
                 <tr><td>Type                 </td><td> &laquo; <input class="text" type="text" name="loc_type"     size="10" value="'
.htmlentities($loc_data['loc_type']).'"> &raquo; Type de location : Studio, T1, T2, T3, T4, T5, Villa, Chateau, etc.)</td></tr>
                <tr><td>Surface                </td><td> &laquo; <input class="text" type="text" name="loc_surface"size="10" value="'
.htmlentities($loc_data['loc_surface']).'"> &raquo; Surface habitable de la location en M²</td></tr>
                <tr><td>Loggia/Terrasse        </td><td> &laquo; <input class="text" type="text" name="loc_loggia" size="10" value="'
.htmlentities($loc_data['loc_loggia']).'"> &raquo; Informations sur les loggias et terrasses</td></tr>
                <tr><td>Loyer                </td><td> &laquo; <input class="text" type="text" name="loc_loyer"     size="10" value="'
.htmlentities($loc_data['loc_loyer']).'"> &raquo; Loyer mensuel hors charges en euros</td></tr>
                <tr><td>Charges                </td><td> &laquo; <input class="text" type="text" name="loc_charges"size="10" value="'
.htmlentities($loc_data['loc_charges']).'"> &raquo; Charges mensuelles en euros</td></tr>
                <tr><td>Frais d\'agence        </td><td> &laquo; <input class="text" type="text" name="loc_frais"     size="10" value="'
.htmlentities($loc_data['loc_frais']).'"> &raquo; Frais d\'agence en euros</td></tr>
                <tr><td>Disponiblité        </td><td> &laquo; <input class="text" type="text" name="loc_dispo"     size="10" value="'
.htmlentities($loc_data['loc_dispo']).'"> &raquo; Date de disposiniblité</td></tr>
                <tr><td>Details                </td><td> &laquo; <input class="text" type="text" name="loc_details"size="10" value="'
.htmlentities($loc_data['loc_details']).'"> &raquo; Commentaires sur l\'offre (160 caractères)</td></tr>
                <tr><td>Image actuelle        </td><td> &laquo; <input class="text" type="text" name="loc_image"     size="10" value="'
.htmlentities($loc_data['loc_image']).'"> &raquo; Photo illustrative de l\'offre</td></tr>
                <tr><td>Nouvelle image       </td><td> &laquo; <input class="text" type="file" size="10"> &raquo; Choisir une nouvelle image sur votre ordinateur</td></tr>
                <tr>
                    <td><input class="button" type="reset" value="Annuler" onclick="javascript:history.go(-1)"></td>
                    <td><input class="button" type="submit" value="Valider"></td>
                </tr>
            </table>
            <input type="hidden" name="loc_id" value="'
.$_GET['edit'].'">
              <input type="hidden" name="send" value="update">
            <input type="hidden" name="MAX_FILE_SIZE" value="500000">
            </form>
            </fieldset>
            '
;
        }
    }
    else {

    
//Ajout des locations
        
print '
        <fieldset>
            <legend>Ajoût d\'une location&nbsp;</legend>
            <form action="loc_admin.php" method="post" name="loc_add" name="loc_edit" enctype="multipart/form-data">
                <i>* Remplissez les champs de votre choix puis cliquer sur "Valider"</i>
                   <table>
                <tr><td width=100>Référence    </td><td> &laquo; <input class="text" type="text" name="loc_ref" size="10"> &raquo; Code de référence correspondant à votre logiciel de gestion</td></tr>
                <tr><td>Localisation        </td><td> &laquo; <input class="text" type="text" name="loc_lieu" size="10"> &raquo; Emplacement géographique de la location</td></tr>
                <tr><td>Type                </td><td> &laquo; <input class="text" type="text" name="loc_type" size="10"> &raquo; Type de location : Studio, T1, T2, T3, T4, T5, Villa, Chateau, etc.)</td></tr>
                <tr><td>Surface                </td><td> &laquo; <input class="text" type="text" name="loc_surface" size="10"> &raquo; Surface habitable de la location en M²</td></tr>
                <tr><td>Loggia                </td><td> &laquo; <input class="text" type="text" name="loc_loggia" size="10"> &raquo; Informations sur les loggias et terrasses</td></tr>
                <tr><td>Loyer                </td><td> &laquo; <input class="text" type="text" name="loc_loyer" size="10"> &raquo; Loyer mensuel hors charges en euros</td></tr>
                <tr><td>Charges                </td><td> &laquo; <input class="text" type="text" name="loc_charges" size="10"> &raquo; Charges mensuelles en euros</td></tr>
                <tr><td>Frais d\'agence        </td><td> &laquo; <input class="text" type="text" name="loc_frais" size="10"> &raquo; Frais d\'agence en euros</td></tr>
                <tr><td>Disponibilité        </td><td> &laquo; <input class="text" type="text" name="loc_dispo" size="10"> &raquo; Date de disposiniblité</td></tr>
                <tr><td>Description            </td><td> &laquo; <input class="text" type="text" name="loc_details" size="10"> &raquo; Commentaires sur l\'offre (160 caractères)</td></tr>
                <tr><td>Image                   </td><td> &laquo; <input class="text" type="file" size="10"> &raquo; Choisir une nouvelle image sur votre ordinateur</td></tr>
                <tr>
                    <td><input class="button" type="reset" value="Effacer"></td>
                    <td><input class="button" type="submit" value="Valider"></td>
                </tr>
             </table>
             </fieldset>
         <input type="hidden" name="send" value="new">
         
        </form>
        '
;



    
//Gestion des locations
        
print '<hr><fieldset><legend>Gestion des locations&nbsp;</legend>';
    
        
$sql 'SELECT * FROM locations ORDER BY loc_id DESC' ;
        
$rc mysql_query($sql,$db_link);
        while(
$loc_data mysql_fetch_array($rc)) {
            print
             
'<table><tr><td width=500>'
            
.'<li>Référence : '            .$loc_data['loc_ref']
            .
'<li>Localisation : '        .$loc_data['loc_lieu']
            .
'<li>Type : '                .$loc_data['loc_type']
            .
'<li>Surface : '            .$loc_data['loc_surface'] . '&nbsp;m²'
            
.'<li>Loggia / Terrasse : '    .$loc_data['loc_loggia']
            .
'<li>Loyer : '                .$loc_data['loc_loyer'] . '&nbsp;€ &nbsp;+&nbsp;'
                                        
.$loc_data['loc_charges'] .'&nbsp;€ de charges'
            
.'<li>Frais d\'agence : '    .$loc_data['loc_frais'] . '&nbsp;€'
            
.'<li>Disponibilité : '        .$loc_data['loc_dispo']
            .
'<li>Description : '        .$loc_data['loc_details']
            .
'<li>Image : '                .$loc_data['loc_image']
            .
'</td><td width=200 align=right><img width=80 height=80 src=img/loc/'.$loc_data['loc_image'].'></td></tr></table>'
            
.'<br><a href="?delete='.$loc_data['loc_id'].'">Supprimer</a> - '
            
.'<a href="?edit='.$loc_data['loc_id'].'">Modifier</a><br><hr>'
            
;
            }
        }
?>
        </fieldset>
        <br>
        </td>
        </tr>
    </table>
    <table class=frame cellpadding=0 cellspacing=0 width=700 height=18 border=1 align=center>
        <tr>
            <td align=center bgcolor=#660000>&copy;2006</td>
        </tr>
    </table>
  </body>
</html>
__________________
L'ignorance n'excuse pas la CONNERIE

Last edited by wuub; 19-07-2006 at 14:12.
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pb création de compte Mail Exchange. TibolouS Windows NT4/2000/2003/2008 Serveur 3 20-01-2009 07:42
Cours de français Benjy Discussions sur le site et/ou le forum 47 01-05-2006 14:47
console d'administration joomla roudoudou Design Web / Graphisme 6 09-01-2006 22:10
Aide pour création de site virus0r Design Web / Graphisme 24 31-05-2004 15:35
Creation de compte Shadow Windows NT4/2000/XP Client 1 16-02-2003 08:44

All times are GMT +2. The time now is 16:53.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.