IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

[Upload] admin panel


Sujet :

Langage PHP

  1. #1
    Invité
    Invité(e)
    Par défaut [Upload] admin panel
    bonjour,

    voila mon script

    up.php (formulaire)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Upload Song</title>
    </head>
     
    <body>
    <h2>::: Upload Song :::</h2>
    <hr>
    <form action="upload.php" enctype="multipart/form-data">
    <table>
    <tr>
    <td>Movie : </td><td><input type="text" name"movie" value="<?php print($movie); ?>" /></td><br />
    </tr>
    <tr>
    <td>Song : </td><td><input type="text" name="song" value="<?php print($song); ?>" /></td><br />
    </tr>
    <tr>
    <td>Image : </td><td><input type="file" name="image" value="<?php print($image); ?>" /></td><br />
    </tr>
    <td>Song url : </td><td><input type="text" name="songurl" value="<?php print($songurl); ?>" /></td><br />
    </table>
    <input type="submit" name="submit" value="envoyer" />
    </form>
    </body>
    </html>


    upload.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>UPLOAD</title>
    </head>
     
    <body>
    <?PHP
    require ("connect.php");
     
    $movie=$_REQUEST["movie"];
      $song=$_REQUEST["song"];
      $songurl=$_REQUEST["songurl"];
     
    if ($_REQUEST["submit"]!=""){
      if(empty($movie)||empty($song)||empty($songurl)) 
          die("ERREUR : tous les champs doivent être remplis.");
    if (is_uploaded_file($_FILES['image']['tmp_name'])){
        move_uploaded_file($_FILES['image']['tmp_name'],'images/'.$_FILES['image']['name']);
        echo "<img src=images/".$_FILES['image']['name'].">";
        $image='images/'.$_FILES['image']['name'];
      }else{die ("Problème d'envoi de fichier [image]");}
     
    $liendb = mysql_connect("$host", "login", "password");
    mysql_select_db("$db");  
    $sql = "INSERT INTO tamilxtreme (movie, song, image, url) ";
    $sql.= " VALUES ('$movie', '$song', '$image', '$url')";
    mysql_query($sql);
     echo "$movie, $song, $image, $url => ajouté sans probleme";
      mysql_close($liendb);
    }
      ?>
    </body>
    </html>

    le problem c'est qu'il ne vaut pas marcher il m'affiche ""ERREUR : tous les champs doivent être remplis."

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    155
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Novembre 2004
    Messages : 155
    Par défaut
    Bonjour,

    un de tes 3 champs (movie,song,songurl) doit etre vide lorsque tu envoies le formulaires

  3. #3
    Invité
    Invité(e)
    Par défaut
    non j'ai essayer ils sont pas vide mais ca me fait ca c'ets ce que je ne comprend pas

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    691
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Décembre 2004
    Messages : 691
    Par défaut
    J'ai une question bete comment des champs de type texte à remplir par l'utilisateur peuvent dejà avoir une valeur transmise en PHP dans ton code.

    La je comprend pas trop.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    155
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Novembre 2004
    Messages : 155
    Par défaut
    et si tu mets ton formulaire en post ça donne quoi?

  6. #6
    Invité
    Invité(e)
    Par défaut
    $_REQUEST par $_POST ?

  7. #7
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par zulot
    J'ai une question bete comment des champs de type texte à remplir par l'utilisateur peuvent dejà avoir une valeur transmise en PHP dans ton code.

    La je comprend pas trop.
    c'est pour pls tard quand je vais modifier les fivhier dans le db

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    155
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Novembre 2004
    Messages : 155
    Par défaut
    tu mets

    <form method=Post ...

  9. #9
    Invité
    Invité(e)
    Par défaut
    ERREUR : tous les champs doivent être remplis.

    up.php (formulaire)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Upload Song</title>
    </head>
     
    <body>
    <h2>::: Upload Song :::</h2>
    <hr>
    <form method="post" action="upload.php"  enctype="multipart/form-data">
    <table>
    <tr>
    <td>Movie : </td><td><input type="text" name"movie" /></td><br />
    </tr>
    <tr>
    <td>Song : </td><td><input type="text" name="song" /></td><br />
    </tr>
    <tr>
    <td>Image : </td><td><input type="file" name="image" /></td><br />
    </tr>
    <td>Song url : </td><td><input type="text" name="songurl" /></td><br />
    </table>
    <input type="submit" value="envoyer" />
    </form>
    </body>
    </html>
    upload.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>UPLOAD</title>
    </head>
     
    <body>
    <?PHP
    require ("connect.php");
     
    if (is_uploaded_file($_FILES['image']['tmp_name']))
      {
        move_uploaded_file($_FILES['image']['tmp_name'],
    	                   'video_images/' . $_FILES['image']['name']);
        echo "<img src=video_images/".$_FILES['image']['name'].">";
     
    	$image = 'video_images/'.$_FILES['image']['name'];
      }
      else
      {
      die ("Problème d'envoi de fichier");
      }
     
      if (empty($_REQUEST['movie']) || empty($_REQUEST['song']) || empty($_REQUEST['songurl'])) 
          die("ERREUR : tous les champs doivent être remplis.");
     
     
    $liendb = mysql_connect("$host", "$login", "$password");
    mysql_select_db("$db");  
    $sql = "INSERT INTO tamilxtreme (movie, song, image, url) ";
    $sql.= " VALUES ('".$_REQUEST['movie']."', '".$_REQUEST['song']."', '$image', '".$_REQUEST['songurl']."')";
    mysql_query($sql);
     echo "ajouté sans probleme";
      mysql_close($liendb);
    //}
      ?>
    </body>
    </html>
    je repost le code, j'ai aporter des modification mais ca amrche toujours pas

  10. #10
    Invité
    Invité(e)
    Par défaut
    j'ai trouver le problem

    j'ai fait un print_r($_REQUEST);

    j'ai vu que movie ne s'afficher pas

    j'ai regarder autour de movie il manquer "=" entre name="movie"

    c'est bete

Discussions similaires

  1. Réponses: 1
    Dernier message: 13/10/2012, 12h34
  2. [MySQL] admin panel pour un Widget wordpress
    Par alban.dev dans le forum PHP & Base de données
    Réponses: 0
    Dernier message: 31/01/2011, 12h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo