Précédent   Forum des professionnels en informatique > PHP > Langage > Formulaires
Formulaires Forum d'entraide sur les formulaires avec PHP. Avant de poster -> FAQ formulaires, Cours de formulaires et Sources de formulaires
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 25/11/2010, 10h32   #1
Nouveau Membre du Club
 
Inscription : mars 2006
Messages : 130
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 130
Points : 32
Points : 32
Par défaut fusion de 2 formulaires

Bonjour j'ai développé 2 scripts pour le site d'une amie, mais comme celle ci est néophyte je voudrais les fusionner afin que l'utilisation soit le plus facile possible il s'agit d'un formulaire d'upload de fichier et l'autre un formulaire d'insert SQL

je ne sais pas comment les fusionner sachant que leur fonctionnement est différent
le premier code qui fait l'upload
Code :
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
 
<?php session_start();
 
include "config/config.php";             //config file inclusion
include "includes/fonctions.inc.php";    //functions inclusion
CloseUpload();                           //Application closing function
include "includes/header.php";           //header inclusion
include "lang/$lang.php";                //language inclusion
echo "<center>";
 
// Detect if you have FTP extension loaded for PHP
 
if(!DetectFtpExtension()) echo $ftpExtensionNotLoaded;
 
// inclusion de la classe de mail si necessaire
// inclusion of the mail class if necessary
if($prevenir_par_mail==1) include "includes/email_mime.class.php";
 
switch($a){
 
//----------------------------------------
// Second Page 
//----------------------------------------
case upload:
$error_id=0;
$error_ftp=0;
 
//----------------------------------------
// authentification
//----------------------------------------
if($identification_nec==1) AuthentificationUser($login, $pass, $user);
 
//----------------------------------------
// file checking
//----------------------------------------
FileChecking($fichier_name, $fichier_size);
 
//----------------------------------------
//Connection to the FTP server
//----------------------------------------
$connection_ftp=@ftp_connect("$ftp_server");
$login_to_ftp=@ftp_login($connection_ftp, $ftp_user, $ftp_pass);
if((!$connection_ftp) || (!$login_to_ftp)) ++$error_ftp;
 
if($error_ftp!=0){
echo $strErrorConnectionFtp."<br>";
logError("Can't connect to FTP server ($ftp_server) ");
makeReturn();
signMTA();
exit;
}
 
//----------------------------------------
//directory change
//----------------------------------------
if(isset($destination))
$dossier_destination = $destination;
else
$dossier_destination = $ftp_rep_defaut;
 
if(!@ftp_chdir($connection_ftp, $dossier_destination)){
echo $strErrorDestinationDirectory."<br><br>";
logError("Can't find destination directory (".$dossier_destination.") ");
makeReturn();
signMTA();
exit;
}
 
//---------------------------------------
// Test Name
//----------------------------------------
$arrayFilesInDir = ftp_nlist($connection_ftp, "./");
$renamed = false;
 
if(in_array($fichier_name, $arrayFilesInDir)) {$newFileName=RenameFile($fichier_name);}
else    {$newFileName = $fichier_name;}
 
//----------------------------------------
// File Upload
//----------------------------------------
$upload = ftp_put($connection_ftp, $newFileName, $fichier, FTP_BINARY);
 
//----------------------------------------
// Upload verification
//----------------------------------------
 
// If Upload Failed
 
if(!$upload){
    logError("Upload failed !");
    echo "<center><h1>Upload</h1>";
    echo $strErrorUploading." ".$newFileName."</center>";
    makeReturn();
   signMTA();
 
    $date_a=date("j/m/y à H:i", time());
 
    if($prevenir_par_mail==1){
        $mail = new mime_mail();
        $mail->to = $Administrator['email'];                
        $mail->subject = "[PHP UPLOAD]".$strErrorUploading." ".$newFileName;                   
       $mail->body = $strErrorUploading." ".$newFileName."\n";
        $mail->body.= "Date: ".$date_a."<br>File: ".$newFileName."\n";
      $mail->body.= "IP: ".$REMOTE_ADDR;
        $mail->body.= "\n\n-----------------------------------------------------------\n";
       $mail->body.= "PHP Upload To My FTP website: http://phpuptomyftp.sourceforge.net\n";
        $mail->from = "phpUpload@YourFtp.com";              
       $mail->send();
    }
} 
 
// If upload OK
else{
 
    logUpload();
 
    echo "<center><h1>Upload</h1>".$strFile." ".$newFileName." (".$fichier_size." octets) ";
    echo $strHasBeenUploaded."<br></center><br><br>";
 
    makeReturn();
    signMTA();    
 
// Email 
    if($prevenir_par_mail==1){
        $mail = new mime_mail();
        $mail->to = $Administrator['email'];                
        $mail->subject = "[PHP UPLOAD]".$strNewFileUpload;
        $mail->body = $strYouReceive;
        $mail->body.= "\n--------------------------------------------------------------\n";
       $mail->body.= $strFile." (".$newFileName.") ".$strHasBeenUploaded." (in ".$ftp_server.")";
        $mail->body.= "\n".$strInTheDirectory." ".$dossier_destination."\n"; 
 
      if($renamed) $mail->body.= $strFileRenamed."\n";
 
        $mail->body.= "\n\n-----------------------------------------------------------\n";
       $mail->body.= "PHP Upload To My FTP website: http://phpuptomyftp.sourceforge.net\n";
        $mail->from = "phpUpload@YourFtp.com";
 
        if($joindre_fichier==1){
            $fichier_attache = fread(fopen("$fichier", "r"), filesize("$fichier"));
            $mail->attach("$fichier_attache", "$newFileName");
        }
 
       $mail->send();
    }
}
break;
 
//----------------------------------------
// Default Page (first page)
//----------------------------------------
default:
 
//log the visitor
logVisiteur();
 
// Display the beginning of the form
DisplayBeginningForm();
 
// if authentification is active, we display the login form
if($identification_nec == 1) DisplayLoginForm();
 
// if directory choosing is active, we display the appropriate form
if($choisir_rep == 1) DisplayDirSelect();
 
// display the end of the form
DisplayEndForm();
signMTA();    
break;
}
?>
et le second code qui fait de l'insert en BDD

Code :
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
 
<?
//// Verification author's area and comment's ////
 
$_POST['Index']=trim($_POST['Index']);
$_POST['Nom']=trim($_POST['Nom']);
$_POST['Photos']=trim($_POST['Photos']);
$_POST['Ref']=trim($_POST['Ref']);
 
if(empty($_POST['Ref']))
{
 echo "Erreur \n";
}
 
else
 {
 
  //// include connection SQL file ////
 
  include("../inc/connect.php");
 
 
  //// Connection to mySQL DB////
 
  @MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible");
  @MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible");
 
 
  //// new title ////
 
     mysql_query("INSERT INTO nanda_serie VALUES (\"$_POST[Index]\",\"$_POST[Nom]\",\"$_POST[Photos]\",\"$_POST[Ref]\")");
  echo "<meta http-equiv=\"refresh\" content=\"0;url=http://www.nanda-lavaquerie.com/frame.php?go=7\">\n ";
 
 
  //// close mySQL DB////
 
  mysql_close();
 }
d'avance merci (en espérant qu'il ne manque pas un bout de code
Baldric de Dol est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/11/2010, 12h38   #2
Membre éprouvé
 
Avatar de radicaldreamer
 
Homme Guillaume
Développeur Web
Inscription : décembre 2007
Messages : 353
Détails du profil
Informations personnelles :
Nom : Homme Guillaume
Âge : 21
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 353
Points : 473
Points : 473
Questions:

- Quelle version de php as-tu? PHP 5.3? (veillez à bien remplir la balise version php lors de la création du post)

- Le FTP est-il distant? (ftp_connect etc...)

- Pourrais-t-on avoir le formulaire HTML?
radicaldreamer est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 05/12/2010, 01h22   #3
Nouveau Membre du Club
 
Inscription : mars 2006
Messages : 130
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 130
Points : 32
Points : 32
Par défaut informations

PHP 5.3

ftp distant (j'utilise ftp expert)

Formulaire HTML (pour la partie ajout de référence dans la BDD)

Code :
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
 
<?
 
//// On inclut le fichier de connexion à la base SQL ////
 
include("../inc/connect.php");
 
echo "<title>Titre</title> \n";
echo "</head> \n";
echo "<body> \n";
 
echo "<form name=\"form\" method=\"post\" action=\"./admin/ajout.php\"> \n";
 
echo "<table border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" width=\"400\" class=\"tableau\"> \n";
echo " <tr>\n";
echo "     <td colspan=\"2\" class=\"row_1\"> \n";
echo "         <b>Ajouter les informations d'une nouvelle photo</b> \n";
echo "     </td> \n";
echo " </tr> \n";
 
echo " <tr>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <b>Index :</b> \n";
echo "     </td>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <input type=\"text\" name=\"Index\" class=\"input1\">il s'agit du numéro de la photo dans la série<font color=red>*</font> \n";
echo "     </td>\n";
echo " </tr>\n";
 
echo " <tr>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <b>Nom de la série :</b> \n";
echo "     </td>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <input type=\"text\" name=\"Nom\" class=\"input1\">Ici on indique le nom de la série, ex: nanda_série A \n";
echo "     </td>\n";
echo " </tr>\n";
 
echo " <tr>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <b>Photos :</b> \n";
echo "     </td>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <input type=\"text\" name=\"Photos\" class=\"input1\">Ici on indique le nom de la photo tel quel, ex: image01.jpg \n";
echo "     </td>\n";
echo " </tr>\n";
 
echo " <tr>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <b>Titre :</b> \n";
echo "     </td>\n";
echo "     <td class=\"row_2\"> \n";
echo "         <input type=\"text\" name=\"Ref\" class=\"input1\">Ici on indique le nom de l'image sans l'extension .jpg, ex: image01 \n";
echo "     </td>\n";
echo " </tr>\n";
 
echo " <tr>\n";
echo "     <td colspan=\"2\" class=\"row_1\">\n";
echo "         <input type=\"submit\" value=\"Envoyer\" class=\"input2\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>*</font> Champs obligatoires\n";
echo "     </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "</form>\n";
 
?>
et le formulaire côté envoie de fichier
Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
echo "<FORM METHOD='POST' ACTION='index.php'>";
echo "<table class='Tableau' border='0' align='center' width='45%' cellpadding='0' callspacing='0'><tr>";
echo "<td width='100%' height='26' colspan='2' background='../img/ftab_fond.gif'><p align='center'>";
echo "<font size='3'><b>Administration</b></font></p></td></tr>";
echo "<tr><td width='50%'><p align='right'><font face='Arial' color='white' size='2'>";
echo "Login :</font></p></td><td width='50%'><p align='left'><input type='text' name='login' class='Forms'></p></td></tr>";
echo "<tr><td width='50%'><p align='right'><font face='Arial' color='white' size='2'>".$strPassword." ";
echo ":</font></p></td><td width='50%'><p align='left'><input type='password' name='pass' class='Forms'></p></td></tr>";
echo "<tr><td width='100%' colspan='2'><p align='center'>";
echo "<INPUT TYPE='SUBMIT' VALUE='Login >>' class='Forms' Onclick=\"this.value='".$strWait."'\">";
   echo "</p></td></tr></table><input type='HIDDEN' name='a' value='auth'></FORM>";
Baldric de Dol est déconnecté   Envoyer un message privé Réponse avec citation 01
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h51.


 
 
 
 
Partenaires

Hébergement Web