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