Wooo, génial, merci beaucoup!
Mais juste pour être sûr: il faut que je crée un fichier inscription.html et un fichier process_inscription.php?
Et je mets les deux sur mon ftp?
Si je veux inclure un champs "Profession", cela donne ceci dans chacun des deux documents?
Bloc de code:
<form name="inscription" method="post" action="process_inscription.php">
<p>
<label for="nom">Nom :</label> <input type="text" name="nom" id="nom" /><br />
<label for="prenom">Prenom :</label> <input type="text" name="prenom" id="prenom" /><br />
[B][I]<label for="profession">Profession :</label> <input type="text" name="profession" id="profession" /><br />[/I][/B]
<label for="email">Email :</label> <input type="text" name="email" id="email" /><br />
<input type="text" name="city" id="city" style="display:none;" />
<input type="submit" name="Envoyer" value="Envoyer" />
</p>
</form>
et
Bloc de code:
<?php
if (isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['email'])) {
if ($_POST['city'] != '') {
header('Location: inscription.html');
}
elseif (!preg_match('!^[a-zA-Z0-9\.\+_-]+@[a-zA-Z0-9\._-]+\.[a-zA-Z]{2,4}$!U', $_POST['email'])) {
echo 'l\'adresse email fourni n\'est pas valide';
}
else {
$headers = 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: '.$_POST['prenom'].' '.$_POST['nom'].' <'.$_POST['email'].'>' . "\r\n";
$subject = '[Incsription] '.$_POST['prenom'].' '.$_POST['nom'];
$mail_content = '<em>Mail envoyer depuis le formulaire d\'inscription du site.</em><br /><br />';
$mail_content .= 'Nom : <strong>'.$_POST['nom'].'</strong><br />';
$mail_content .= 'Prenom : <strong>'.$_POST['prenom'].'</strong><br />';
$mail_content .= 'Mail : <a href="mailto:'.$_POST['email'].'">'.$_POST['email'].'</a><br />';
if (mail('[email protected]', $subject, $mail_content, $headers)) {
$headers = 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: tonsite <[email protected]>' . "\r\n";
$subject = '[Incsription] '.$_POST['prenom'].' '.$_POST['nom'];
$mail_content = '<em>Ceci est un mail de confirmation de votre inscription.</em><br /><br />Vous avez envoyé : <br />';
$mail_content .= 'Nom : <strong>'.$_POST['nom'].'</strong><br />';
$mail_content .= 'Prenom : <strong>'.$_POST['prenom'].'</strong><br />';
[B][I] $mail_content .= 'Profession : <strong>'.$_POST['profession'].'</strong><br />';[/I][/B]
$mail_content .= 'Mail : <a href="mailto:'.$_POST['prenom'].'">'.$_POST['email'].'</a><br />';
if (mail($_POST['email'], $subject, $mail_content, $headers)) {
echo 'Votre inscription a bien été envoyée et un mail de confirmation de votre inscription vous a été envoyé !';
}
else {
echo 'Votre inscription a bien été envoyée';
}
}
else {
echo 'Une erreur est survenue, votre inscription n\'a pas pu être envoyée<br />Merci de bien vouloir réessayer.';
}
}
}
else {
header('Location: inscription.html');
}
?>
Mmmh... j'oublie des trucs dans le second texte non?
Et sinon si je veux placer un chtit texte d'intro pour dire que "blablabla vous devez remplir ces champs", je peux le mettre où?
Encore un grand grand merci!
A.