[size=150][b]Formulaire conçu avec le logiciel Créa form[/b][/size]
[i]Si des personnes le veulent je peux l'envoyer[/i]
[b]Les erreurs affichées lorsque que je valide le formulaire sans le remplir[/b]
[code]
( ! ) Notice: Undefined index: id_46 in C:\wamp\www\Energy-Trad\envoi.php on line 7
Call Stack
# Time Memory Function Location
1 0.0480 156096 {main}( ) ..\envoi.php:0
( ! ) Parse error: syntax error, unexpected '"\n"' (T_CONSTANT_ENCAPSED_STRING) in C:\wamp\www\Energy-Trad\mimemail.php on line 150
Call Stack
# Time Memory Function Location
1 0.0480 156096 {main}( ) ..\envoi.php:0
[/code]
[size=150][b]Code HTML/Javascript[/b][/size]
[code]
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<center>
<font size="6pt" color="#5E6463" ><u>Formulaire de contact</u></font>
</center><br />
<table border="0" cellpadding="0" cellspacing="0" class="border">
<tr>
<td class="bg_color">
<div class="margins">
<form name="formulaire" action="envoi.php" method="post" enctype=
"multipart/form-data" onsubmit="return ValidForm(this);">
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td valign="top">
<p align="right">Civilitée : </p><input type='hidden'
name='hidden_43' value='' />
</td>
<td>
<table width="100%">
<tr>
<td><input type="checkbox" name="id_43" value=
"Madame" /> <span class="mef">Madame</span></td>
<td><input type="checkbox" name="id_43" value=
"Monsieur" /> <span class="mef">Monsieur</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p align="right">Nom : <span class="obli">*</span></p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_2" name=
"id_2" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Prénom : </p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_34" name=
"id_34" value='' class="format" /></td>
</tr>
<tr>
<td valign="top">
<p align="right">Vous etes un(e) : </p>
</td>
<td>
<table width="100%">
<tr>
<td><input type="radio" id="id_46" name="id_46" value=
"Particulier" /> <span class=
"mef">Particulier</span></td>
<td><input type="radio" id="id_46" name="id_46" value=
"Institutionnel" /> <span class=
"mef">Institutionnel</span></td>
<td><input type="radio" id="id_46" name="id_46" value=
"Professionnel" /> <span class=
"mef">Professionnel</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p align="right">Société : </p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_36" name=
"id_36" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Téléphone : </p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_37" name=
"id_37" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Votre e-mail : <span class=
"obli">*</span></p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_38" name=
"id_38" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Adresse : </p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_39" name=
"id_39" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Code postal : </p>
</td>
<td><input type="text" size="10" maxlength="10" id="id_40" name=
"id_40" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Ville : <span class="obli">*</span></p>
</td>
<td><input type="text" size="50" maxlength="50" id="id_41" name=
"id_41" value='' class="format" /></td>
</tr>
<tr>
<td>
<p align="right">Message : </p>
</td>
<td>
<textarea rows="10" cols="50" name="id_45" id="id_45" class=
"format" onkeyup="countChars('id_45', 'txtmsg45', 900)">
</textarea>
<div id="txtmsg45">
</div>
</td>
</tr>
<tr>
<td valign="top">
<p align="right">Je souhaite etre informé des
nouveautés : </p><input type='hidden' name='hidden_9'
value='' />
</td>
<td>
<table width="100%">
<tr>
<td><input type="checkbox" name="id_9" value=
"Oui" /> <span class="mef">Oui</span></td>
<td><input type="checkbox" name="id_9" value=
"Non" /> <span class="mef">Non</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p align="right">Je souhaite etre contacter par : </p>
</td>
<td><select id="id_10" name="id_10">
<option value="E-mail">
E-mail
</option>
<option value="Téléphone">
Téléphone
</option>
<option value="Fax">
Fax
</option>
</select></td>
</tr>
<tr>
<td>
<p align="right">Ajouter votre CV </p>
</td>
<td><input type="file" id="id_44" name="id_44" class=
"format" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2" >
<table width="100%"align="center" id="middle">
<tr>
<td align="center" width="30%"><input type="reset" name="reset" value="Annuler" class="reset" /></td>
<td width="0%"><input type="submit" name=
"reset" value="Valider" class="submit" /></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>
</form>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table><script language="javascript" type="text/javascript">
//<![CDATA[
function getElementsByClass(className) {
var elems = document.getElementById(className);
elems.className="error";
}
function init_error(className){
var elems = document.getElementById(className);
elems.className='format';
}
function init_error_ff(className){
var elems = document.getElementsByTagName(className);
elems.className='format';
}
function getElementsByClass_ff(className){
var elems = document.getElementsByTagName(className);
elems.className="error";
}function ValidForm(){
init_error_ff('id_43');
formulaire.hidden_43.value=valeur_cbx(formulaire.id_43);
init_error('id_2');
if (document.formulaire.id_2.value.length==0) {
alert('Vous devez saisir le champ Nom : ! ');
getElementsByClass('id_2');
document.formulaire.id_2.focus();
return false;
}
if (formulaire.id_2.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_2');
formulaire.id_2.focus();
return false;
}
init_error('id_34');
if (formulaire.id_34.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_34');
formulaire.id_34.focus();
return false;
}
init_error('id_46');
init_error('id_36');
if (formulaire.id_36.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_36');
formulaire.id_36.focus();
return false;
}
init_error('id_37');
if (formulaire.id_37.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_37');
formulaire.id_37.focus();
return false;
}
init_error('id_38');
if (document.formulaire.id_38.value.length==0) {
alert('Vous devez saisir le champ Votre e-mail : ! ');
getElementsByClass('id_38');
document.formulaire.id_38.focus();
return false;
}
if (formulaire.id_38.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_38');
formulaire.id_38.focus();
return false;
}
if (isNotEmpty(formulaire.id_38.value) && isNotEmailAdress(formulaire.id_38.value)){
alert("L'email n'est pas correcte");;
getElementsByClass('id_38');
formulaire.id_38.focus();
return false;
}
init_error('id_39');
if (formulaire.id_39.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_39');
formulaire.id_39.focus();
return false;
}
init_error('id_40');
if (formulaire.id_40.value.length>10) {
alert('Vous ne pouvez pas saisir plus de 10 caractères.! ');
getElementsByClass('id_40');
formulaire.id_40.focus();
return false;
}
init_error('id_41');
if (document.formulaire.id_41.value.length==0) {
alert('Vous devez saisir le champ Ville : ! ');
getElementsByClass('id_41');
document.formulaire.id_41.focus();
return false;
}
if (formulaire.id_41.value.length>50) {
alert('Vous ne pouvez pas saisir plus de 50 caractères.! ');
getElementsByClass('id_41');
formulaire.id_41.focus();
return false;
}
init_error('id_45');
if (formulaire.id_45.value.length>900) {
alert('Vous ne pouvez pas saisir plus de 900! ');
getElementsByClass('id_45');
formulaire.id_45.focus();
return false;
}
if (formulaire.id_45.value.length<1) {
alert('Vous devez saisir au moins 1 caractères.! ');
getElementsByClass('id_45');
formulaire.id_45.focus();
return false;
}
init_error_ff('id_9');
formulaire.hidden_9.value=valeur_cbx(formulaire.id_9);
init_error('id_10');
init_error('id_44');
}
//-->
//]]>
</script>[/code]
[size=150][b]Code PHP "mimemail.php"[/b][/size]
[code]<?php
/* This is Version 1.4
* Notes from
[email protected] 25 Mar 2000:
* Improvements: Multi attachmends in one e-mail, ability to post html & plain trext, up to 3x speed improved.
* USSAGE - mimetype example for attacment
* $m = new CMIMEMail($to,$from,$subject);
* $m->mailbody("This is simply text","<html><body><h1>This is HTML text</h1>");
* $m->attach("example.html","text/html",$filebody);
* $m->attachFile("resume.gif","image/gif");
* $m->send();
*******
* To Do:
* 1 Test with different Mail clients
*/
class CMIMEMail {
var $to;
var $boundary;
var $smtp_headers;
var $filename_real;
var $body_plain;
var $body_html;
var
$atcmnt;
var $atcmnt_type;
function CMIMEMail($to,$from,$subject,$priority=3) {
$this->to=$to; $this->from=$from;
$this->subject=$subject; $this->priority=$priority;
$this->boundary="----=_NextPart_".time()."_".md5(time())."_";
}
function mailbody( $plain, $html="" ) {
$this->body_plain=$plain;
$this->body_html=$html;
}
function attach( $name, $content_type, $data ) {
}
function attachfile_raw( $fname, $mailFileName, $content_type ) {
if($f=@fopen($fname,"r")) {
$this->atcmnt[$mailFileName]=fread($f,filesize($fname));
$this->atcmnt_type[$mailFileName]=$content_type;
fclose($f);
}
}
function attachfile( $fname, $content_type ) {
//attachfile_raw($fname,$fname,$content_type);
if($f=@fopen($fname,"r")) {
$this->atcmnt[$fname]=fread($f,filesize($fname));
$this->atcmnt_type[$fname]=$content_type;
fclose($f);
}
}
function clear() {
unset( $atcmnt );
unset( $atcmnt_type );
}
function makeheader() {
$out ="From: ".$this->from."\n";
$out.="Reply-To: ".$this->from."\n";
$out.="MIME-Version: 1.0\n".
"Content-Type: multipart/mixed;\n\t boundary=\"".$this->boundary."\"\n".
"X-Priority: ".$this->priority."\n".
"X-Mailer: IziMailing.com )\n";
return $out;
}
function makebody() {
$boundary2= "----=_NextAttachedPart_".time()."_".md5(time()+101)."_";
$out="";
if( " ".$this->body_html!=" " ) {
$out="\nThis is a multi-part message in MIME format.\n\n";
$out.="--".$this->boundary."\nContent-Type: multipart/alternative;\n\tboundary=\"$boundary2\"\n";
$out.=$body_plan.
$boundary2"\n"Content-Type: text/plain.
# "Content-Disposition: inline\n".
"Content-Transfer-Encoding: quoted-printable\n\n".
$this->body_plain.
"\n\n--$boundary2\n".
"Content-Type: text/html\n".
# "Content-Disposition: attachment;\n\tfilename=\"message.html\"\n".
"Conent-Transfer-Encoding: quoted-printable\n".
"\n$this->body_html\n\n".
"--$boundary2--\n";
} else {
$out="\n\n".$this->body_plain."\n\n";
$out.="--".$this->boundary."\n".
"Content-Type: text/plain\n".
"Content-Transfer-Encoding: quoted-printable\n\n".
$this->body_plain.
"\n\n--".$this->boundary.
"\n";
}
if( is_array( $this->atcmnt_type ) ) {
reset( $this->atcmnt_type);
while( list($name, $content_type) = each($this->atcmnt_type) ) {
$out.="\n--".$this->boundary."\nContent-Type: $content_type\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename=\"$name\"\n\n".
chunk_split(base64_encode($this->atcmnt[$name]))."\n";
}
}
$out.="\n--".$this->boundary."--\n";
return $out;
}
function send(){
mail( $this->to, $this->subject, $this->makebody(),$this->makeheader() );
//echo $this->to."<br>";
//echo $this->subject."<br>";
//echo $this->makebody()."<br>";
//echo $this->makeheader()."<br>";
}
function sendto($email){
mail( $email, $this->subject, $this->makebody(),$this->makeheader() );
}
}
?>[/code]
[size=150][b]Code PHP "envoi.php"[/b][/size]
[code]<?PHP
$url_upload='';
$data='';
$data.='Civilitée :='.$_POST["hidden_43"].'<br>';
$data.='Nom :='.$_POST["id_2"].'<br>';
$data.='Prénom :='.$_POST["id_34"].'<br>';
$data.='Vous etes un(e) :='.$_POST["id_46"].'<br>';
$data.='Société :='.$_POST["id_36"].'<br>';
$data.='Téléphone :='.$_POST["id_37"].'<br>';
$data.='Votre e-mail :='.$_POST["id_38"].'<br>';
$data.='Adresse :='.$_POST["id_39"].'<br>';
$data.='Code postal :='.$_POST["id_40"].'<br>';
$data.='Ville :='.$_POST["id_41"].'<br>';
$data.='Message :='.$_POST["id_45"].'<br>';
$data.='Je souhaite etre informé des nouveautés :='.$_POST["hidden_9"].'<br>';
$data.='Je souhaite etre contacter par :='.$_POST["id_10"].'<br>';
$chiffre=rand(100,999).rand(100,999).rand(100,999);
$content_dir = 'upload/';
$content_dir.=$chiffre."/";
$envoi_mail_pj=1;
IF (!file_exists("./upload")){
umask(0);
@mkdir("./upload",0777);
}
IF (!file_exists("./upload/$chiffre")){
umask(0);
@mkdir("./upload/$chiffre",0777);
}$nb_fic=0;
$url_chemin=str_replace("envoi.php","",$_SERVER["PHP_SELF"]);
$tmp_file = $_FILES['id_44']['tmp_name'];
if ($tmp_file<>""){
if( !is_uploaded_file($tmp_file) )
{
exit("Le fichier est introuvable");
}
if ( $_FILES['id_44']['size']>2750000){
exit("Le poids de votre fichier est trop important.");
}
// on vérifie maintenant l'extension
$type_file1 = explode(".",$_FILES['id_44']['name']);
$type_file=strtolower($type_file1[count($type_file1)-1]);
{
exit("Ce type de fichier n'est pas autorisé.");
}
// on copie le fichier dans le dossier de destination
$name_file = $_FILES['id_44']['name'];
if( @preg_match('#[\x00-\x1F\x7F-\x9F/\\]#', $name_file))
{
exit("Nom de fichier non valide");
}
else {
if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
{
exit("Impossible de copier le fichier dans $content_dir");
}
else {
$url_upload.='fichier à télécharger sur le serveur : '.$url_chemin.$content_dir . $name_file.'<br>';
$nb_fic++;
$tab_fic[$nb_fic][0]=$content_dir . $name_file;
$tab_fic[$nb_fic][1]=$_FILES['id_44']['type'];
}
}
}
$data.=$url_upload;
include('mimemail.php');
if (!$fp=fopen('./upload/'.$chiffre.'/renseignements.htm','w')){}else {;
fputs($fp,$data);
fclose($fp);}
$m = new CMIMEMail('Vous <
[email protected]>','<
[email protected]>','Contact - Energy Trad');
$m->mailbody($data,$data);
if ($nb_fic>0 && $envoi_mail_pj==1){
$x=1;
while ($x<=count($tab_fic)){
$m->attachFile($tab_fic[$x][0],$tab_fic[$x][1]);
$x++;
}
}
$m->send();
$msg_client='Nous avons bien pris en compte votre email, nous vous répondrons dès que possible.
______________________
Energy-Trad';
$msg_client_txt='';
$mail_client=$_POST['id_38'];
$m = new CMIMEMail('Vous <'.$mail_client.'>','<
[email protected]>','Confirmation / Retour');
$m->mailbody($msg_client_txt,$msg_client);
$m->send();
header("location: ");
exit();
?>
[/code]
J'ai déjà éradiquer quelques autres erreurs, et j'ai du adapter le formulaire dans la page de mon site web, de base lors de la génération du formulaire avec le logiciel Créa form il est dans sa page par défaut avec <html><head><title></title></head></html>
Logiciel de base de donnée utilisée "WampServeur 5.5.12", et pour l'envoi de mails factice j'ai installé sendmail.
Merci de votre aide ! =P~