Bonjour,
Je voudrais vous faire part d'un problème sur mon formulaire de contact.
le soucis est, au lieu de recevoir le mail dans ma boite mail
Voici les 4 variables à configurer pour recevoir les messages sur sa boite mail perso.
Le Formulaire :
Voici les 2 fichiers à configurer : contact.php
et xmlHttpRequest.php
merci pour votre aide
Modifié par gold3neye (11 Jan 2007 - 09:19)
Je voudrais vous faire part d'un problème sur mon formulaire de contact.
le soucis est, au lieu de recevoir le mail dans ma boite mail
$yourEmail = 'user@example.com';
le mail est envoyé à la personne qui tape son mail dans le formulaire <label for="posEmail">Email:</label>
<input class="text" type="text" size="25" name="posEmail" id="posEmail" />
Ce qui n'est pas l'effet voulu, vous êtes d'accord.Voici les 4 variables à configurer pour recevoir les messages sur sa boite mail perso.
<?php
// Change the 4 variables below
$yourName = 'John Doe';
$yourEmail = 'user@example.com';
$yourSubject = 'testJax';
$referringPage = 'http://www.example.com/testJax/index.php';
// No need to edit below unless you really want to. It's using a simple php mail() function. Use your own if you want
Le Formulaire :
<body>
<h2>AJAX Contact Form</h2>
<p id="loadBar" style="display:none;">
<strong>Sending Email via slick AJAX. Hold on just a sec…</strong>
<img src="img/loading.gif" alt="Loading..." title="Sending Email" />
</p>
<p id="emailSuccess" style="display:none;">
<strong style="color:green;">Success! Your Email has been sent.</strong>
</p>
<div id="contactFormArea">
<form action="scripts/contact.php" method="post" id="cForm">
<fieldset>
<label for="posName">Name:</label>
<input class="text" type="text" size="25" name="posName" id="posName" />
<label for="posEmail">Email:</label>
<input class="text" type="text" size="25" name="posEmail" id="posEmail" />
<label for="posRegard">Regarding:</label>
<input class="text" type="text" size="25" name="posRegard" id="posRegard" />
<label for="posText">Message:</label>
<textarea cols="50" rows="5" name="posText" id="posText"></textarea>
<label for="selfCC">
<input type="checkbox" name="selfCC" id="selfCC" value="send" /> Send CC to self
</label>
<label>
<input class="submit" type="submit" name="sendContactEmail" id="sendContactEmail" value=" Send Email " />
</label>
</fieldset>
</form>
</div>
Voici les 2 fichiers à configurer : contact.php
<?php
// Change the 4 variables below
$yourName = 'John Doe';
$yourEmail = 'user@example.com';
$yourSubject = 'testJax';
$referringPage = 'http://www.example.com/testJax/index.php';
// No need to edit below unless you really want to. It's using a simple php mail() function. Use your own if you want
function cleanPosUrl ($str) {
return stripslashes($str);
}
if ( isset($_POST['sendContactEmail']) )
{
$to = $yourEmail;
$subject = $yourSubject.': '.$_POST['posRegard'];
$message = cleanPosUrl($_POST['posText']);
$headers = "From: ".cleanPosUrl($_POST['posName'])." <".$_POST['posEmail'].">\r\n";
$headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
$mailit = mail($to,$subject,$message,$headers);
if ( @$mailit ) {
header('Location: '.$referringPage.'?success=true');
}
else {
header('Location: '.$referringPage.'?error=true');
}
}
?>
et xmlHttpRequest.php
<?php
// change the 4 variables below
$yourName = 'John Doe';
$yourEmail = 'user@example.com';
$yourSubject = 'testJax';
$referringPage = 'http://www.example.com/testJax/index.php';
// no need to change the rest unless you want to. You could add more error checking but I'm gonna do that later in the official release
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
echo '<resultset>';
function cleanPosUrl ($str) {
$nStr = $str;
$nStr = str_replace("**am**","&",$nStr);
$nStr = str_replace("**pl**","+",$nStr);
$nStr = str_replace("**eq**","=",$nStr);
return stripslashes($nStr);
}
if ( $_GET['contact'] == true && $_GET['xml'] == true && isset($_POST['posText']) ) {
$to = $yourName;
$subject = 'AJAX Mail: '.cleanPosUrl($_POST['posRegard']);
$message = cleanPosUrl($_POST['posText']);
$headers = "From: ".cleanPosUrl($_POST['posName'])." <".cleanPosUrl($_POST['posEmail']).">\r\n";
$headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
$mailit = mail($to,$subject,$message,$headers);
if ( @$mailit )
{ $posStatus = 'OK'; $posConfirmation = 'Success! Your Email has been sent. Hope you enjoyed your stay.'; }
else
{ $posStatus = 'NOTOK'; $posConfirmation = 'Your Email could not be sent. Please try back at another time.'; }
if ( $_POST['selfCC'] == 'send' )
{
$ccEmail = cleanPosUrl($_POST['posEmail']);
@mail($ccEmail,$subject,$message,"From: Yourself <".$ccEmail.">\r\nTo: Yourself");
}
echo '
<status>'.$posStatus.'</status>
<confirmation>'.$posConfirmation.'</confirmation>
<regarding>'.cleanPosUrl($_POST['posRegard']).'</regarding>
';
}
echo' </resultset>';
?>
merci pour votre aide
Modifié par gold3neye (11 Jan 2007 - 09:19)