bonjour jcm,
Merci de te pencher sur mon probleme.
C'est bon cela fonctionne!!
Merci beaucoup.
j'ai un autre petit probleme sur ce formulaire je voudrais juste rajouter un champs : WEBSITE
voici le code de mon formulaire :
<?php
// ---------------------------------- EDIT HERE --------------------------------- //
/* Your email where the results of the contact form will be sent to. */
$dest = "email@email.com,email@email.com";
/* The full path to your upload directory. This will appear in the email you'll get so that you can retrieve the uploaded files easily. */
$up_full = "http://www.monsite/formulaire/upload/";
/* The relative path to your upload directory from this script. This is an important settings : if the files are not uploaded, chances are that this is not set properly.
Configuration example : if this file is at www.domain.net/contact.php and your upload directory is www.domain.net/upload/, the setting should be :
$up_dir = "./upload/";
*/
$up_dir = "./upload/";
/* The number of upload fields you want on the form. Put 0 if you don't want any. */
$UploadNum = "0";
/*Host mail functions. Possible values are 0 or 1. See below:
0 is for most hosts (default value).
1 is for Online.Net (Online). */
$online_isp = "0";
// --------------------------------------------------------------------------------- //
if(isset($_POST["submit"]))
{
// ------------------------ Fields Verification Process ------------------------- //
$Nada = '';
$From = $_POST['From'];
$Msg = $_POST['Msg'];
$Name = $_POST['Name'];
$Firstname = $_POST['Firstname'];
$Companyname = $_POST['Companyname'];
$Adress = $_POST['Adress'];
$City = $_POST['City'];
$Country = $_POST['Country'];
$Country = $_POST['website'];
if(empty($From))
{
$Nada.="Email field is empty !<br>";
}
if(empty($Name))
{
$Nada.="Name field is empty !<br>";
}
if(empty($Firstname))
{
$Nada.="Firstname field is empty !<br>";
}
if(empty($Companyname))
{
$Nada.="Companyname field is empty !<br>";
}
if(empty($Adress))
{
$Nada.="Adress field is empty !<br>";
}
if(empty($City))
{
$Nada.="City field is empty !<br>";
}
if(empty($Country))
{
$Nada.="Country field is empty !<br>";
}
$noway = "$Nada" ;
if(empty($Nada) &&
eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$",$From))
{
$ok = TRUE;
}
elseif(!empty($Nada) &&
eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$",$From))
{
$ok = FALSE;
}
else
{
$ml = "Your email address is invalid !<br>";
$ok = FALSE;
}
// ------------------------------------------------------------------------- //
// ----------------------------- Upload Files ------------------------------ //
$status = '';
$new_name = '';
$uploaded = '';
$get_files = '';
$all_names = '';
for($i=0;$i<count($_FILES["fileup"]["tmp_name"]);$i++)
{
$name=$_FILES["fileup"]["name"][$i];
$temp=$_FILES["fileup"]["tmp_name"][$i];
$size=$_FILES["fileup"]["size"][$i];
$type=$_FILES["fileup"]["type"][$i];
if($size > 0)
{
global $up_dir, $all_names;
$length = 16;
$key_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$rand_max = strlen($key_chars) - 1;
for ($i = 0; $i < $length; $i++)
{
$rand_pos = rand(0, $rand_max);
$rand_key[] = $key_chars{$rand_pos};
}
$rand_pass = implode('', $rand_key);
$boom = strlen($Msg) * strlen($From);
$timer = time()* rand(0, $boom);
$timer = $timer . '-' . $rand_pass;
$new_name = $timer . "-" . $name;
$new_name = str_replace(" ","_",$new_name);
@move_uploaded_file($temp, $up_dir . $new_name);
$all_names.= "$new_name\n";
}
}
// ------------------------------------------------------------------------- //
// ----------------------------- Upload Messages --------------------------- //
if(empty($all_names))
{
$status = "No files uploaded.";
$uploaded = "No files sent.";
}
else
{
$status = "File(s) successfully uploaded.";
$uploaded = "Yes !\nFiles:";
$get_files = "\nGet the file(s): $up_full";
}
//--------------------------------------------------------------------------- //
// ----------------------------- Mail Builder ------------------------------ //
if($ok == "TRUE")
{
$referer = $_SERVER["HTTP_REFERER"];
$subject = "Catalog Order Europe";
$body = "Origin: $referer\n";
$body.="\n***** Results *****\n\n";
if(count($_POST))
{
while(list($key, $val) = each($_POST))
{
$body.="$key : $val\n";
}
}
$body.="\n\n";
$body.="Upload: $uploaded\n";
$body.="$all_names\n";
$body.="$get_files\n";
$body.="*************************\n";
if($online_isp == "1")
{
if(!email("feedback",$dest,$sujet,$body))
{
print "An error occured during mail delivery <br>";
}
}
else
{
$header = '';
$header.= 'From: "' . $Name . '" <' . $From . ">\r\n";
$header.= 'Reply-To: "' . $Name . '" <' . $From . ">\r\n";
$header.= "X-Mailer: PHP/" . phpversion();
if(!mail($dest, $subject, $body, $header ))
{
print "An error occured during mail delivery <br>";
}
}
// ------------------------------------------------------------------------- //
// ---------------------------- Success Message ---------------------------- //
?>
<html><head><title>Success !</title><link rel="stylesheet" href='contact.css' type="text/css" media="screen" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="left">
<table width="34%" height="76%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"> <table width="537" height="459" border="0" cellpadding="0" cellspacing="0" background="images/fond.jpg">
<tr>
<td colspan="2"><div align="center"><br>
Thank you !<br>
<br>
Your message has been successfully sent to the webmaster and should
receive an answer shortly.<br>
<br>
<?php echo $status; ?> <br>
<p> </p>
<p> </p>
<p>
<input type=button value="Close" onClick="javascript:self.close();" />
</p>
</div></tr>
</table>
<div align="left"></div></td>
</tr>
</table>
</div>
</body>
</html>
<?php
}
// ------------------------------------------------------------------------- //
else
{
// ----------------------------- Error Message ----------------------------- //
?>
<html><head><title>Error !</title><link rel="stylesheet" href='contact.css' type="text/css" media="screen" /></head><body bgcolor="white">
<center><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle">
<table width="537" height="459" border="0" cellpadding="2" cellspacing="1">
<tr>
<td colspan="2"><div align="center"><br><b>
<?php
echo $noway;
echo $ml;
?>
</b><p><br><br>Your message could not be processed properly. Please note the error messages above and press the back button to try again.<br> If the problem still remains <a href="mailto:contact@invad.com">contact the webmaster</a> to fix the problem.</p>
<p> </p><p> </p>
<p><a href='Javascript:history.go(-1)'>BACK</a></p><br></div>
</tr></table>
</td></tr></table></center></body>
</html>
<?php
// ------------------------------------------------------------------------- //
}
}
else
{
$num = 0;
$upload_box = '';
while($num < $UploadNum)
{
$num++;
$upload_box.= "<tr><td><font size='-1' face='verdana'> File $num:</font></td><td><input name='fileup[]' type='file'></td>";
}
?>
<html>
<head>
<title>Europe Catalog Order</title>
<link rel="stylesheet" href='contact.css' type="text/css" media="screen" />
</head>
<body>
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="middle">
<table width="537" height="459" border="0" align="center" cellpadding="0" cellspacing="0" bordercolordark="#FFFFFF" background="images/fond.jpg" cols="1">
<tr><td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<table border="0" height="100" align="center">
<tr>
<td height="5"> </td>
<td height="5" width="218" align="right"><font color="#FF0000">The fields with * are required !</font> </td>
</tr>
<tr>
<td height="5"> </td>
<td height="5"> </td>
</tr
><tr>
<td height="5" width="218">email* : </td><td height="5" width="249"><input type="text" size="30" maxlength="255" name="From" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr><tr><td height="5" width="218">Last Name* : </td><td height="5" width="249"><input type="text" size="30" name="Name" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr>
<tr><td height="5" width="218">First Name* : </td><td height="5" width="249"><input type="text" size="30" name="Firstname" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr>
<tr><td height="5" width="218">Company Name* : </td><td height="5" width="249"><input type="text" size="30" name="Companyname" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr>
<tr><td height="5" width="218">Adress* : </td><td height="5" width="249"><textarea name="Adress" cols="23" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;"></textarea></td></tr>
<tr><td height="5" width="218">Zip Code : </td><td height="5" width="249"><input type="text" size="30" name="Zipcode" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr>
<tr><td height="5" width="218">City* : </td><td height="5" width="249"><input type="text" size="30" name="City" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr>
<tr><td height="5" width="218">Country* : </td><td height="5" width="249"><input type="text" size="30" name="Country" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr></table>
<p align="center"><b>Message : </b><br><textarea name="Msg" cols="45"></textarea><br></p>
<table width="95%" border="0" align="center"><tr align="center"><td> </td>
<?php echo $upload_box; ?></tr></table>
<p align="center"><br>
<input type="reset" name="reset" value=" Clear ">
<input type="submit" name="submit" value=" Send " style="background-color:#CCCCCC">
</p>
</form>
</td></tr></table>
</td></tr></table>
</body>
</html>
<?php } ?>
J'ai essayé de changer deja...mais sans succés
Encore merci pour ton aide
Modifié par brad689 (08 May 2006 - 13:57)