FORUM

forum / PHP / Traiter un formulaire email avec piece jointe

Vous n êtes pas connecté

Page : 1 2

Traiter un formulaire email avec piece jointe

Auteurs Messages
filou80 Posté à 00h22 le 16 Apr 14

Membre inscrit le 25/03/2014
Messages : 120
Localisation : somme
Bonsoir

De nouveau sa fonctionne plus, sa me met : Extension du fichier incorrecte.
pourtant j'ai essayer avec plusieurs format mais rien.

Voici le code formulaire :



<?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 = "index.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 = "accesrefuse.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;
}
}

mysql_select_db($database_ludoinformatique, $ludoinformatique);
$query_Recordset1 = "SELECT * FROM inscription";
$Recordset1 = mysql_query($query_Recordset1, $ludoinformatique) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
input {
  border-radius: 15px;
 
}

input,textarea, select {
 border-radius: 10px 10px;
 -moz-border-radius: 10px;
 padding-left: 3px;
 background-color:transparent;
 font-size: 12px;
 font-family: "Lucida Calligraphy";
}
input[type=text]
{
 border-radius: 15px;
 background-color:transparent;
 padding-left: 5px;
 font-family: "Lucida Calligraphy";
 font-size: 12px;
}
#Tableau_01 tr td table {
 font-family: "Lucida Calligraphy";
 font-size: 12px;
}
</style>
<title>ContactPJ</title>
<meta name="Description" content="Site personnel script blogue et divers">
<meta name="Keywords" lang="fr" content="Internet, Informatique, Site internet, et autre">
<META http-equiv="Content-Language" content="fr">
<meta name="Reply-to" content="[email=ludoinformatique80@ludoinformatique80.fr]ludoinformatique80@ludoinformatique80.fr[/email]">
<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="http://ludoinformatique80.fr">
<meta name="Expires" content="never">
<meta name="Date-Creation-ddmmyyyy" content="26112013">
<meta name="Date-Revision-ddmmyyyy" content="26112013">
<link rel="shortcut icon" href="/images/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="http://ludoinformatique80.fr/images/favicon.ico">
<link rel="icon" type="image/png" href="http://ludoinformatique80.fr/images/favicon.png"">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">
<link rel="icon" type="image/png" href="/images/favicon.png">
<link href='http://ludoinformatique80.fr/images/favicon.ico' rel='icon' type='image/x-icon'>
<style type="text/css">
a:link {
 color: #000;
 text-decoration: none;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: none;
}
a:active {
 text-decoration: none;
}
#Tableau_01 tr td table tr td form table tr td {
 font-size: 14px;
}
body,td,th {
 font-family: "Lucida Calligraphy";
 font-size: 12px;
}
</style>
</head>
<body bgcolor="#3464B0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Sans titre-1.psd) -->
<table width="800" height="900" border="0" align="center" cellpadding="0" cellspacing="0" id="Tableau_01">
 <tr>
  <td width="800" height="164" align="center" valign="bottom" background="images/Sans-titre-1_01.jpg"><table width="95%" height="40" border="0" align="center">
    <tr>
      <td width="85%" align="right" valign="middle" style="font-family: 'Lucida Calligraphy'"><?php $toc= $_SESSION['MM_Username'];
$sql = mysql_query("SELECT login FROM inscription WHERE mail='$toc'" );
$data = mysql_fetch_array($sql); 
echo '<p>Connecter sous  '.$data['login'].' </p>';?></td>
      <td width="15%" align="right" valign="middle">&nbsp;<a href="<?php echo $logoutAction ?>">Se déconnecter</a></td>
       </tr>
     </table></td>
 </tr>
 <tr>
  <td width="800" height="46" align="right" valign="bottom" background="images/Sans-titre-1_02.jpg">&nbsp;</td>
 </tr>
 <tr>
  <td width="800" height="626" align="left" valign="top" background="images/Sans-titre-1_03.jpg"><table width="95%" border="0" align="center">
    <tr>
      <td><form action="actioncontactpj.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
        <table width="100%" border="0" align="center">
          <tr>
            <td colspan="2" align="center">Formulaire de contact</td>
             </tr>
          <tr>
            <td width="15%">&nbsp;</td>
            <td width="85%"><input type="hidden"  name="nom" type="text" id="nom" value="<?php $toc= $_SESSION['MM_Username'];
$sql = mysql_query("SELECT nom FROM inscription WHERE mail='$toc'" );
$data = mysql_fetch_array($sql); 
echo '  '.$data['nom'].' ';?>" /></td>
             </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="hidden"  name="prenom" type="text" id="nom" value="<?php $toc= $_SESSION['MM_Username'];
$sql = mysql_query("SELECT prenom FROM inscription WHERE mail='$toc'" );
$data = mysql_fetch_array($sql); 
echo '  '.$data['prenom'].' ';?>" /></td>
             </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="hidden"  name="mail" type="text" id="nom" value="<?php $toc= $_SESSION['MM_Username'];
$sql = mysql_query("SELECT mail FROM inscription WHERE mail='$toc'" );
$data = mysql_fetch_array($sql); 
echo '  '.$data['mail'].' ';?>" /></td>
             </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="hidden"  name="login" type="text" id="nom" value="<?php $toc= $_SESSION['MM_Username'];
$sql = mysql_query("SELECT login FROM inscription WHERE mail='$toc'" );
$data = mysql_fetch_array($sql); 
echo '  '.$data['login'].' ';?>" /></td>
             </tr>
          <tr>
            <td>Sujet :</td>
            <td><input name="sujet" type="text" id="sujet" onfocus="if(this.value==this.defaultValue)value=''" onblur="if(this.value=='')value=this.defaultValue;" value="Sujet du message" size="45" /></td>
             </tr>
          <tr>
            <td align="left" valign="top">Message :</td>
            <td><textarea name="message" cols="45" rows="5" id="message" onFocus="if(this.value==this.defaultValue)value=''" onBlur="if(this.value=='')value=this.defaultValue;">Votre message</textarea></td>
             </tr>
          <tr>
            <td>Fichier :</td>
            <td><label for="fileField"></label>
               <input type="file" name="fileField" id="fileField"></td>
             </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
             </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="button" id="button" value="Envoyer">
               <input type="reset" name="button2" id="button2" value="Réinitialiser"></td>
             </tr>
           </table>
         </form></td>
       </tr>
     </table></td>
 </tr>
 <tr>
  <td width="800" height="64" background="images/Sans-titre-1_04.jpg">&nbsp;</td>
 </tr>
</table>
<!-- End Save for Web Slices -->
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>


filou80 Posté à 18h38 le 28 Jan 15

Membre inscrit le 25/03/2014
Messages : 120
Localisation : somme
Bonjour

Certain vont dire encore lui....

comment faire une redirection après envoi du message, car j'ai mis sa en script mais je reste sur la même page :

Merci par avance


Header("Location: http://yakasolution.fr/mercimessage.php")


filou80 Posté à 21h10 le 29 Jan 15

Membre inscrit le 25/03/2014
Messages : 120
Localisation : somme
Bonsoir

Je me répond a moi même mais sis cela peut aider quelqu'un :

echo "<script language='Javascript'>document.location='mercimessage.php'</script>";


Samomoi

Page : 1 2