Probleme javascript php
Résolu
wifi
-
wifi -
wifi -
bonjour j ai une newsletter qui fonctionne le mail renseigné est bien envoyé sur mon email mais mon script pour le format de l adresse email ne fonctionne pas je ne vois pas pourquoi
merci
[code]
<?php
// N'afficher que les erreurs, pas les avertissements...
ini_set("error_reporting", "E_ALL & ~E_NOTICE");
// Adresse de réception du formulaire
$email_dest = "test@test.com";
if ($_POST['envoi']) {
// E-mail headers:
$headers ="MIME-Version: 1.0 \n";
$headers .="From: visiteurs du site <test@test.com>\n";
$headers .="Content-Type: text/html; charset=iso-8859-1 \n";
$subject = "Inscription newsletter";
$partie_entete = "<html><head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body bgcolor=#FCE1AA>";
for ($a=1; $a<= $_POST['nbre_champs_texte']; $a++)
if ($_POST['nbre_zone_email'] != 0) {
$partie_zone_email = "<font face='Verdana' size='2' color='#8e1a2c'>" . $_POST['titre_email'] . " = " . $_POST['zone_email'] . "</font><br>";
}
$fin = "</body></html>";
$sortie = $partie_entete . $partie_zone_email. $fin ;
// Send the e-mail
if (@!mail($email_dest,$subject,$sortie,$headers)) {
echo("Forms sending impossible");
} else { // Closing if !mail...
// Renvoi à la page de remerciement
header("Location:thanks.html");
exit();
} // Fin du else
} // Closing if edit
?><html><head><title></title><script language="JavaScript">function verifSelection() {if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
} if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
}
invalidChars = " /:,;'"
for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters?
badChar = invalidChars.charAt(i)
if (document.mail_form.zone_email.value.indexOf(badChar,0) > -1) {
alert("Invalid Character. Please check.")
document.mail_form.zone_email.focus()
return false
}
}
atPos = document.mail_form.zone_email.value.indexOf("@",1) // there must be one "@" symbol
if (atPos == -1) {
alert('Please enter "@".')
document.mail_form.zone_email.focus()
return false
}
if (document.mail_form.zone_email.value.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
alert('only one "@" symbol. Please check.')
document.mail_form.zone_email.focus()
return false
}
periodPos = document.mail_form.zone_email.value.indexOf(".",atPos)
if (periodPos == -1) { // and at least one "." after the "@"
alert('and at least one "." after the "@". Please check.')
document.mail_form.zone_email.focus()
return false
}
if (periodPos+3 > document.mail_form.zone_email.value.length) { // must be at least 2 characters after the
alert('must be at least 2 characters after the ".". Please check.')
document.mail_form.zone_email.focus()
return false
}} // Fin de la fonction
</script>
</head>
<body>
<form name="mail_form" method="post" action="forms.php" onSubmit="return verifSelection()">
<div align="center"></div>
<p align="center">
<table width="566" border="0" align="center">
<p align="center">
</p><tr>
<td width><font face="Verdana" color="8e1a2c" size="2">E mail *</font></td>
<td width><input name="zone_email" type="text"></td>
</tr><tr>
<td valign="top"><input name="nbre_champs_texte" type="hidden" id="nbre_champs_texte" value="1">
<input name="nbre_zones_texte" type="hidden" value="1">
<input name="nbre_zone_email" type="hidden" value="1">
<input name="titre_email" type="hidden" value="E mail"></td>
<td><div align="center">
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="envoi" value="Send">
</div></td>
</tr>
</table>
<div align="center"></div>
<div align="left">
<span style="color: #8e1a2c;">
* Mandatory fields
</span>
</div>
</form></body></html>/code
merci
[code]
<?php
// N'afficher que les erreurs, pas les avertissements...
ini_set("error_reporting", "E_ALL & ~E_NOTICE");
// Adresse de réception du formulaire
$email_dest = "test@test.com";
if ($_POST['envoi']) {
// E-mail headers:
$headers ="MIME-Version: 1.0 \n";
$headers .="From: visiteurs du site <test@test.com>\n";
$headers .="Content-Type: text/html; charset=iso-8859-1 \n";
$subject = "Inscription newsletter";
$partie_entete = "<html><head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body bgcolor=#FCE1AA>";
for ($a=1; $a<= $_POST['nbre_champs_texte']; $a++)
if ($_POST['nbre_zone_email'] != 0) {
$partie_zone_email = "<font face='Verdana' size='2' color='#8e1a2c'>" . $_POST['titre_email'] . " = " . $_POST['zone_email'] . "</font><br>";
}
$fin = "</body></html>";
$sortie = $partie_entete . $partie_zone_email. $fin ;
// Send the e-mail
if (@!mail($email_dest,$subject,$sortie,$headers)) {
echo("Forms sending impossible");
} else { // Closing if !mail...
// Renvoi à la page de remerciement
header("Location:thanks.html");
exit();
} // Fin du else
} // Closing if edit
?><html><head><title></title><script language="JavaScript">function verifSelection() {if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
} if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
}
invalidChars = " /:,;'"
for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters?
badChar = invalidChars.charAt(i)
if (document.mail_form.zone_email.value.indexOf(badChar,0) > -1) {
alert("Invalid Character. Please check.")
document.mail_form.zone_email.focus()
return false
}
}
atPos = document.mail_form.zone_email.value.indexOf("@",1) // there must be one "@" symbol
if (atPos == -1) {
alert('Please enter "@".')
document.mail_form.zone_email.focus()
return false
}
if (document.mail_form.zone_email.value.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
alert('only one "@" symbol. Please check.')
document.mail_form.zone_email.focus()
return false
}
periodPos = document.mail_form.zone_email.value.indexOf(".",atPos)
if (periodPos == -1) { // and at least one "." after the "@"
alert('and at least one "." after the "@". Please check.')
document.mail_form.zone_email.focus()
return false
}
if (periodPos+3 > document.mail_form.zone_email.value.length) { // must be at least 2 characters after the
alert('must be at least 2 characters after the ".". Please check.')
document.mail_form.zone_email.focus()
return false
}} // Fin de la fonction
</script>
</head>
<body>
<form name="mail_form" method="post" action="forms.php" onSubmit="return verifSelection()">
<div align="center"></div>
<p align="center">
<table width="566" border="0" align="center">
<p align="center">
</p><tr>
<td width><font face="Verdana" color="8e1a2c" size="2">E mail *</font></td>
<td width><input name="zone_email" type="text"></td>
</tr><tr>
<td valign="top"><input name="nbre_champs_texte" type="hidden" id="nbre_champs_texte" value="1">
<input name="nbre_zones_texte" type="hidden" value="1">
<input name="nbre_zone_email" type="hidden" value="1">
<input name="titre_email" type="hidden" value="E mail"></td>
<td><div align="center">
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="envoi" value="Send">
</div></td>
</tr>
</table>
<div align="center"></div>
<div align="left">
<span style="color: #8e1a2c;">
* Mandatory fields
</span>
</div>
</form></body></html>/code
A voir également:
- Probleme javascript php
- Easy php - Télécharger - Divers Web & Internet
- Telecharger javascript - Télécharger - Langages
- Expert php pinterest - Télécharger - Langages
- A javascript error occurred in the main process - Forum Windows
- A javaScript error occurred in the main process - Forum Handicap / Accessibilté
5 réponses
rien a voir avec le serveur c'est au niveau de la vérification javascript
essayes avec cette fonction:
essayes avec cette fonction:
function verifSelection() { if(mail_form.zone_email.value == "") { alert("Veuillez entrer votre adresse email"); mail_form.zone_email.focus(); return false; } var exp=new RegExp("^[\\w\\-]+(\\.[\\w\\-]+)*@[\\w\\-]+(\\.[\\w\\-]+)*\\.[\\w\\-]{2,}$", "i"); if(mail_form.zone_email.value !="" && !exp.test(mail_form.zone_email.value)){ alert("Adresse email non valide "); mail_form.zone_email.focus(); return false; } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question