Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2398 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Script pour recevoir message et fichier

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Script pour recevoir message et fichier

n°2222087
filou80
Posté le 11-03-2014 à 19:27:35  profilanswer
 

Bonjour
 
 Je suis entrain de faire un site internet, et j'aurai aimer faire une page de contact chose déjà faite.
 Sur cette page je récupère automatiquement le nom prénom mail etc...la personne peut taper un message et me déposer un fichier, qui celui irai dans un dossier chez mon hébergeur.
 J'aurai aimer être averti par mail du message et des infos saisie ainsi que le nom du fichier,
 J'ai fait un fichier action.php
 celui ci fonctionne a moitié car le fichier et bien mis dans le dossier chez mon hébergeur mais je reçoit aucun message.
 Voici le script j'utilise Dreamweaver

<?php require_once('Connections/ludoinformatique.php'); ?>
 
<?php
 
//initialize the session
 
if (!isset($_SESSION)) {
 
  session_start();
 
}
 
 
 
// ** Logout the current user. **
 
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
 
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "" )){
 
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
 
}
 
 
 
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true" )){
 
  //to fully log out a visitor we need to clear the session varialbles
 
  $_SESSION['MM_Username'] = NULL;
 
  $_SESSION['MM_UserGroup'] = NULL;
 
  $_SESSION['PrevUrl'] = NULL;
 
  unset($_SESSION['MM_Username']);
 
  unset($_SESSION['MM_UserGroup']);
 
  unset($_SESSION['PrevUrl']);
 
 
 
  $logoutGoTo = "abientot.php";
 
  if ($logoutGoTo) {
 
    header("Location: $logoutGoTo" );
 
    exit;
 
  }
 
}
 
?>
 
<?php
 
if (!isset($_SESSION)) {
 
  session_start();
 
}
 
$MM_authorizedUsers = "";
 
$MM_donotCheckaccess = "true";
 
 
 
// *** Restrict Access To Page: Grant or deny access to this page
 
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {  
 
  // For security, start by assuming the visitor is NOT authorized.  
 
  $isValid = False;  
 
 
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.  
 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank.  
 
  if (!empty($UserName)) {  
 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.  
 
    // Parse the strings into arrays.  
 
    $arrUsers = Explode(",", $strUsers);  
 
    $arrGroups = Explode(",", $strGroups);  
 
    if (in_array($UserName, $arrUsers)) {  
 
      $isValid = true;  
 
    }  
 
    // Or, you may restrict access to only certain users based on their username.  
 
    if (in_array($UserGroup, $arrGroups)) {  
 
      $isValid = true;  
 
    }  
 
    if (($strUsers == "" ) && true) {  
 
      $isValid = true;  
 
    }  
 
  }  
 
  return $isValid;  
 
}
 
 
 
$MM_restrictGoTo = "accerefuser.php";
 
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {    
 
  $MM_qsChar = "?";
 
  $MM_referrer = $_SERVER['PHP_SELF'];
 
  if (strpos($MM_restrictGoTo, "?" )) $MM_qsChar = "&";
 
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)  
 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
 
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
 
  header("Location: ". $MM_restrictGoTo);  
 
  exit;
 
}
 
?>
 
<?php
 
if (!function_exists("GetSQLValueString" )) {
 
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "" )  
 
{
 
  if (PHP_VERSION < 6) {
 
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  }
 
 
 
  $theValue = function_exists("mysql_real_escape_string" ) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
 
 
  switch ($theType) {
 
    case "text":
 
      $theValue = ($theValue != "" ) ? "'" . $theValue . "'" : "NULL";
 
      break;    
 
    case "long":
 
    case "int":
 
      $theValue = ($theValue != "" ) ? intval($theValue) : "NULL";
 
      break;
 
    case "double":
 
      $theValue = ($theValue != "" ) ? doubleval($theValue) : "NULL";
 
      break;
 
    case "date":
 
      $theValue = ($theValue != "" ) ? "'" . $theValue . "'" : "NULL";
 
      break;
 
    case "defined":
 
      $theValue = ($theValue != "" ) ? $theDefinedValue : $theNotDefinedValue;
 
      break;
 
  }
 
  return $theValue;
 
}
 
}
 
 
 
$colname_Recordset1 = "-1";
 
if (isset($_GET['mail'])) {
 
  $colname_Recordset1 = $_GET['mail'];
 
}
 
mysql_select_db($database_ludoinformatique, $ludoinformatique);
 
$query_Recordset1 = sprintf("SELECT login FROM inscription WHERE mail = %s", GetSQLValueString($colname_Recordset1, "text" ));
 
$Recordset1 = mysql_query($query_Recordset1, $ludoinformatique) or die(mysql_error());
 
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
 
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
 
<html xmlns="<a href="http://www.w3.org/1999/xhtml" rel="nofollow" target="_blank">http://www.w3.org/1999/xhtml</a>">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<meta name="description" content="Site personnel d'echange entre amis et divers,Crack wii">
 
<meta name="keywords" lang="fr" content="Internet, Informatique, Telephone, Site internet, Crack wii, et autre">
 
<META HTTP-EQUIV="Content-Language" content="fr">
 
<meta name="reply-to" content="ludoinformatique80@ludoinformatique80.fr">
 
<meta name="category" content="Internet">
 
<meta name="robots" content="index, follow">
 
<meta name="distribution" content="global">
 
<meta name="revisit-after" content="1 days">
 
<meta name="author" lang="fr" content="Ludo">
 
<meta name="copyright" content="">
 
<meta name="generator" content="Dreamweaver">
 
<meta name="identifier-url" content="<a href="http://ludoinformatique80.fr" rel="nofollow" target="_blank">http://ludoinformatique80.fr</a>">
 
<meta name="expires" content="never">
 
<meta name="Date-Creation-ddmmyyyy" content="26112013">
 
<meta name="Date-Revision-ddmmyyyy" content="26112013">
 
 
 
<link rel="shortcut icon" href="favicon.ico" />
 
 
 
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
 
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
 
<link rel="shortcut icon" type="image/x-icon" href="<a href="http://ludoinformatique80.fr/images/favicon.ico" rel="nofollow" target="_blank">http://ludoinformatique80.fr/images/favicon.ico</a>" />
 
<link rel="icon" type="image/png" href=<a href="http://ludoinformatique80.fr/images/favicon.png" rel="nofollow" target="_blank">http://ludoinformatique80.fr/images/favicon.png</a>" />
 
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico" />
 
<link rel="icon" type="image/png" href="/images/favicon.png" />
 
<link href='<a href="http://ludoinformatique80.fr/images/favicon.ico" rel="nofollow" target="_blank">http://ludoinformatique80.fr/images/favicon.ico</a>' rel='icon' type='image/x-icon'/>
 
 
 
<title>Traitement</title>
 
<!-- TemplateEndEditable -->
 
<style type="text/css">
 
body {
 
 font-family: "Lucida Calligraphy";
 
 font-size: 14px;
 
 margin-left: 0px;
 
 margin-top: 0px;
 
 margin-right: 0px;
 
 margin-bottom: 0px;
 
}
 
.deconnecter {
 
 font-size: 9px;
 
}
 
a:link {
 
 text-decoration: none;
 
}
 
a:visited {
 
 text-decoration: none;
 
}
 
a:hover {
 
 text-decoration: none;
 
}
 
a:active {
 
 text-decoration: none;
 
}
 
</style>
 
<!-- TemplateBeginEditable name="head" -->
 
<!-- TemplateEndEditable -->
 
</head>
 
 
 
<body>
 
<table width="75%" border="0" align="center">
 
  <tr>
 
    <td align="center"><img src="images/logo.png" width="50" height="75" alt="logo" /></td>
 
    <td align="center"><img src="images/ludoinformatique.png" width="674" height="100" /></td>
 
  </tr>
 
</table>
 
<table width="75%" border="0" align="center">
 
  <tr>
 
    <td width="88%" align="right"><a href="<?php echo $logoutAction ?>" class="deconnecter">Déconnecter</a></td>
 
    <td width="12%" align="right">
 
 <?php $toc= $_SESSION['MM_Username'];
 
$sql = mysql_query("SELECT login FROM inscription WHERE mail='$toc'" );  
 
$data = mysql_fetch_array($sql);  
 
echo '<p>Bonjour  '.$data['login'].' </p>';?></td>
 
  </tr>
 
</table>
 
<table width="100%" border="0" align="center">
 
  <tr>
 
    <td bgcolor="#5F5BFC"> </td>
 
  </tr>
 
</table>
 
<table width="75%" border="0" align="center">
 
  <tr>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td><?php
 
 
 
//Récupération des variables<br />
 
//Fichier nom du fichiers
 
$nomFichier  = $_FILES['fichier']['name'] ;
 
$tailleFichier  = $_FILES['fichier']['size'] ;
 
$nomTmp      = $_FILES['fichier']['tmp_name'] ;
 
$typeFichier   = $_FILES['fichier']['type'] ;
 
$error           = $_FILES['fichier']['error'] ;
 
 
 
$TO = "ludoinformatique@orange.fr";
 
 
 
$h  = "From: " . $TO;
 
 
 
$message = "";
 
 
 
while (list($key, $val) = each($HTTP_POST_VARS)) {
 
  $message .= "$key : $val\n";
 
}
 
 
 
mail($TO, $nomFichier, $message, $h);
 
 
 
 
 
 
 
echo( "Voilà les données du fichier envoyé: <br>\n Nom : <b>".$nomFichier.
 
   "</b><br>\n Taille : <b>".$tailleFichier.
 
   "</b><br>\n Type de fichier => <b>".$typeFichier."</b><br>" ) ;
 
 
 
 
 
?></td>
 
  </tr>
 
  <tr>
 
    <td><?php //nom du fichier
 
if ($_FILES["fichier"]["name"]=="" )
 
{
 
 echo "<b>veuillez entrer un fichier</b>";
 
 exit();
 
}
 
else
 
{
 
 //verification du poids du fichier
 
 if ($_FILES["fichier"]["size"]>900000)
 
 {
 
  echo "<b>veuillez selectionner un fichier moins gros</b>";
 
  exit();
 
 }  
 
 //verification du type  
 
 if (($_FILES["fichier"]["type"]=="image/jpeg" ) || ($_FILES["fichier"]["type"]=="image/gif" ) || ($_FILES["fichier"]["type"]=="image/png" ) || ($_FILES["fichier"]["type"]=="image/rar" ) || ($_FILES["fichier"]["type"]=="multipart/x-zip" ) || ($_FILES["fichier"]["type"]=="application/msword" ) || ($_FILES["fichier"]["type"]=="image/docx" ) || ($_FILES["fichier"]["type"]=="image/xls" ) || ($_FILES["fichier"]["type"]=="image/xlsx" ) || ($_FILES["fichier"]["type"]=="image/xlsm" ) || ($_FILES["fichier"]["type"]=="image/exe" ) || ($_FILES["fichier"]["type"]=="application/pdf" ) || ($_FILES["fichier"]["type"]=="image/" ))
 
 {
 
  //si le fichier et la taille est bon et le type name est bon
 
 
 
  $nomFichier=$_FILES['fichier']['name'];
 
  $extension=explode(".",$nomFichier);
 
  $extension=$extension[1];
 
  if (($extension=="jpg" ) || ($extension=="png" ) || ($extension=="gif" ) || ($extension=="zip" ) || ($extension=="rar" ) || ($extension=="doc" ) || ($extension=="docx" ) || ($extension=="xls" ) || ($extension=="xlsx" ) || ($extension=="xlsm" ) || ($extension=="exe" ) || ($extension=="pdf" ) || ($extension=="" ))
 
  {
 
 //verification d'extention
 
  $nomTmp=$_FILES['fichier']['tmp_name'] ;
 
  echo "";
 
 
 
  $chemin = "./upload/" ;
 
 
 
  if (copy($nomTmp,$chemin.$nomFichier))
 
  echo("<br>Le telechargement à reussi" ) ;
 
 
 
  else
 
  echo("<br>Le telechargement à échoué" ) ;
 
  }//
 
 
 
 
 
  else
 
  {
 
  echo "le fichier a une mauvaise extension";
 
  exit();  
 
  }
 
 
 
 
 
 }  
 
 else
 
 {
 
  echo "<b>veuillez inserer un fichier image</b>";
 
 }Header("Location: <a href="http://ludoinformatique80.fr/" rel="nofollow" target="_blank">http://ludoinformatique80.fr/</a>" );
 
}
 
 
 
?></td>
 
  </tr>
 
</table>
 
<table width="75%" border="0" align="center">
 
</table>
 
<p> </p>
 
<p> </p>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
 
<html xmlns="<a href="http://www.w3.org/1999/xhtml" rel="nofollow" target="_blank">http://www.w3.org/1999/xhtml</a>">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
 
 
 
 
<body>
 
<p>
 
  <?php  
 
 
 
 
 
 
 
/*if ($_POST["nom"]=="" )
 
{
 
 echo "<b>veuillez entrer votre nom</b>";
 
 exit();
 
}
 
*/?>
 
</p>
 
 
 
<p> </p>
 
<p>  </p>
 
<table width="80%" border="0" align="center">
 
  <tr>
 
    <td><?php echo @$_POST["nom"]; ?></td>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td><?php echo @$_POST["prenom"]; ?></td>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td><?php echo @$_POST["nom"]; ?></td>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td><?php echo @$_POST["adresse"]; ?></td>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td><?php echo @$_POST[""]; ?></td>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td><?php
 
 //verification de liste a cocher
 
 for ($i=0;$i<count($_POST["fruit"]);$i++)
 
 {
 
 echo $_POST["fruit"][$i]."<br>";
 
 };?>
 
    <td> </td>
 
  </tr>
 
  <tr>
 
    <td>  
 
    <td><?php echo @$_POST["radio2"];?></td>
 
  </tr>
 
  <tr>
 
    <td>  
 
    <td><?php echo @$_POST["connu"];?></td>
 
  </tr>
 
  <tr>
 
    <td><?php for ($i=0;$i<count($_POST["connu2"]);$i++)
 
 {
 
 echo $_POST["connu2"][$i]."<br>";
 
 };?></td>  
 
    <td> </td>
 
  </tr>
 
</table>
 
</body>
 
</html>
 
<?php
 
mysql_free_result($Recordset1);
 
?>
 
</body>
 
</html>


 
 

mood
Publicité
Posté le 11-03-2014 à 19:27:35  profilanswer
 

n°2222111
filou80
Posté le 12-03-2014 à 10:24:06  profilanswer
 

salut  
voila le formulaire que je voudrais envoyer : http://ludoinformatique80.fr/inscription.php
j'aurai aimer recevoir le message ainsi que le nom de la piece jointe par mail  et que celle ci soit dans mon dossier chez mon hebergeur.
 
 
cordialement


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Script pour recevoir message et fichier

 

Sujets relatifs
générer un fichier json avec java[FORTRAN] Lecture d'un fichier:problème récupération en-tête +mesures
Activer un fichier Word à partir d'une macroScript VBS
Stockage d'un fichier dans l'exe et écriture sur HDD à la prem. exec.Script Dos à transformer en SHELL
Script multijoueur par Socket TCPscript batch kill processus + copie de fichiers
[HELP] modificateur de plusieur fichier texteScript Php prise de Rendez vous
Plus de sujets relatifs à : Script pour recevoir message et fichier


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR