A voir également:
- Script radio button
- Script vidéo youtube - Guide
- Radio française - Télécharger - Médias et Actualité
- Ghost script - Télécharger - Polices de caractères
- Script les visiteurs pdf - Forum Cinéma / Télé
- Microsoft activation script - Accueil - Windows
6 réponses
Bonsoir,
Expose ici le code HTML de ton formulaire et le script PHP en utilisant la balise code (symbole <>) et on tentera de résoudre ton problème... @+
Expose ici le code HTML de ton formulaire et le script PHP en utilisant la balise code (symbole <>) et on tentera de résoudre ton problème... @+
Voici donc ce que je mets dans le script html:
<form action="#" id="contactform">
<fieldset>
<input type="radio" name="sexe" value="Mr">Mr
<input type="radio" name="sex" value="Mme">Mme<br /><br />
<label>Nom</label><br />
<input type="text" name="name" class="textfield" id="name" value="" /><br />
<label>Email</label><br />
<input type="text" name="email" class="textfield" id="email" value="" /><br />
<label>Sujet</label><br />
<input type="text" name="subject" class="textfield field-nomargin" id="subject" value="" /><br />
<label>Message</label><br />
<textarea name="message" id="message" class="textarea" cols="2" rows="7"></textarea>
<input type="submit" name="submit" class="input-submit" id="buttonsend" value="" />
<span class="loading" style="display: none;">Un moment s'il vous plait..</span>
</fieldset>
</form>
...
<form action="#" id="contactform">
<fieldset>
<input type="radio" name="sexe" value="Mr">Mr
<input type="radio" name="sex" value="Mme">Mme<br /><br />
<label>Nom</label><br />
<input type="text" name="name" class="textfield" id="name" value="" /><br />
<label>Email</label><br />
<input type="text" name="email" class="textfield" id="email" value="" /><br />
<label>Sujet</label><br />
<input type="text" name="subject" class="textfield field-nomargin" id="subject" value="" /><br />
<label>Message</label><br />
<textarea name="message" id="message" class="textarea" cols="2" rows="7"></textarea>
<input type="submit" name="submit" class="input-submit" id="buttonsend" value="" />
<span class="loading" style="display: none;">Un moment s'il vous plait..</span>
</fieldset>
</form>
...
...La suite ici:
La partie js:
$(document).ready(function() {
$('#buttonsend').click( function() {
var name = $('#name').val();
var subject = $('#subject').val();
var sexe = $('#sexe').val();
var email = $('#email').val();
var message = $('#message').val();
$('.loading').fadeIn('fast');
if (name != "" && subject != "" && email != "" && message != "" && sexe != "")
{
$.ajax(
{
url: './sendemail.php',
type: 'POST',
data: "sexe=" + sexe + "&name=" + name + "&subject=" + subject + "&email=" + email + "&message=" + message,
success: function(result)
{
$('.loading').fadeOut('fast');
if(result == "email_error") {
$('#email').css({"border":"1px solid #ffb6b6"}).next('.require').text(' !');
} else {
$('#sexe, #name, #subject, #email, #message').val("");
$('<div class="success-contact">Votre message nous est bien parvenu. Merci! </div>').insertBefore('#contactFormArea');
$('.success-contact').fadeOut(5000, function(){ $(this).remove(); });
}
}
}
);
return false;
}
else
{
$('.loading').fadeOut('fast');
if( name == "") $('#name').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
if(subject == "") $('#subject').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
if(email == "" ) $('#email').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
if(message == "") $('#message').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
return false;
}
});
$('#name, #subject, #email,#message').focus(function(){
$(this).css({"background":"#ffffff","border":"1px solid #d5d5d5"});
});
});
La partie js:
$(document).ready(function() {
$('#buttonsend').click( function() {
var name = $('#name').val();
var subject = $('#subject').val();
var sexe = $('#sexe').val();
var email = $('#email').val();
var message = $('#message').val();
$('.loading').fadeIn('fast');
if (name != "" && subject != "" && email != "" && message != "" && sexe != "")
{
$.ajax(
{
url: './sendemail.php',
type: 'POST',
data: "sexe=" + sexe + "&name=" + name + "&subject=" + subject + "&email=" + email + "&message=" + message,
success: function(result)
{
$('.loading').fadeOut('fast');
if(result == "email_error") {
$('#email').css({"border":"1px solid #ffb6b6"}).next('.require').text(' !');
} else {
$('#sexe, #name, #subject, #email, #message').val("");
$('<div class="success-contact">Votre message nous est bien parvenu. Merci! </div>').insertBefore('#contactFormArea');
$('.success-contact').fadeOut(5000, function(){ $(this).remove(); });
}
}
}
);
return false;
}
else
{
$('.loading').fadeOut('fast');
if( name == "") $('#name').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
if(subject == "") $('#subject').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
if(email == "" ) $('#email').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
if(message == "") $('#message').css({"background":"#FFFCFC","border":"1px solid #ffb6b6"});
return false;
}
});
$('#name, #subject, #email,#message').focus(function(){
$(this).css({"background":"#ffffff","border":"1px solid #d5d5d5"});
});
});
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
$sexe = $_POST['sexe'];
if(strlen($_POST['name']) < 1 ){
echo 'email_error';
}
else if(strlen($email) < 1 ) {
echo 'email_error';
}
else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) {
echo 'email_error';
}
else if(strlen($message) < 1 ){
echo 'email_error';
} else {
$email_message="\n\n" .
"Sexe: " .
$sexe .
"\n" .
"Name: " .
ucwords($name) .
"\n" .
"Email: " .
$email .
"\n" .
"Comments: " .
"\n" .
$message .
"\n" .
"\n\n" ;
$email_message = trim(stripslashes($email_message));
mail($mailto, $subject, $email_message, "From: \"$vname\" <".$email.">\nReply-To: \"".ucwords($name)."\" <".$email.">\nX-Mailer: PHP/" . phpversion() );
}
if(strlen($_POST['name']) < 1 ){
echo 'email_error';
}
else if(strlen($email) < 1 ) {
echo 'email_error';
}
else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) {
echo 'email_error';
}
else if(strlen($message) < 1 ){
echo 'email_error';
} else {
$email_message="\n\n" .
"Sexe: " .
$sexe .
"\n" .
"Name: " .
ucwords($name) .
"\n" .
"Email: " .
$email .
"\n" .
"Comments: " .
"\n" .
$message .
"\n" .
"\n\n" ;
$email_message = trim(stripslashes($email_message));
mail($mailto, $subject, $email_message, "From: \"$vname\" <".$email.">\nReply-To: \"".ucwords($name)."\" <".$email.">\nX-Mailer: PHP/" . phpversion() );
}