[PHP-JS] Erreur : modification d'URL après rechargement de page
Bonjour.
J'ai un formulaire qui se compose ainsi :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <form name="forml" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
if($_POST['action'] == 'submitted') {
if((empty($nom ))
||(empty($prenom ))
||(empty($sujet2 ))
||(empty($mess ))
||(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$",$email)))
echo "ERREUR";
else
{
$adress = "web@strix.fr";
$sujet = "$_POST[sujet2]";
$from = "From: ".$_POST[email]."\n";
$from .= "MIME-version: 1.0\n";
$from .= "Content-type: text/html; charset= iso-8859-1\n";
$message="
$_POST[nom] $_POST[prenom]<br>
$_POST[societe]<br>
$_POST[email]<br><br>
$_POST[sujet2]<br>
$_POST[mess]";
mail($adress, $sujet, $message, $from);
}
$insertGoTo = "http://www.strix.fr/sondmerci.php?lang=$lang";
// if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
// $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
// $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
// }
header(sprintf("Location: %s", $insertGoTo));
}
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Nom</td>
<td><input name="nom" type="text" id="nom" value="<?php echo $nom ; ?>"><span class="obl">*</span></td>
</tr>
<tr>
<td>Prénom</td>
<td><input name="prenom" type="text" id="prenom" value="<?php echo $prenom ; ?>"><span class="obl">*</span></td>
</tr>
<tr>
<td>Société</td>
<td><input name="societe" type="text" id="societe" value="<?php echo $societe ; ?>"></td>
</tr>
<tr>
<td>E-mail</td>
<td><input name="email" type="text" id="email" value="<?php echo $email ; ?>"><span class="obl">*</span></td>
</tr>
<tr>
<td>Sujet</td>
<td><input name="sujet2" type="text" id="sujet2" value="<?php echo $sujet2 ; ?>"></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="mess" cols="68" rows="9" id="mess"><?php echo $mess ; ?></textarea></td>
</tr>
<tr>
<td> </td>
<td><span class="obl">* Champs obligatoires</span></td>
</tr>
</table>
<table cellpadding="2" cellspacing="0">
<tr>
<td class="centre" colspan="3"><input name="Annuler" type="reset" id="Annuler2" value="<?php echo annule; ?>">
<input type="hidden" name="action" value="submitted">
<input name="Envoyer" type="submit" id="Envoyer2" value="<?php echo envoie; ?>">
</td>
</tr>
</table>
</form> |
Alors le formulaire marche en grande partie, les infos sont vérifiées et si elles sont bonnes, je reçois bien un mail.
Mais voici les problèmes que je rencontre :
[Résolu] 1 / Que le formulaire soit valide ou pas, l'erreur suivante apparait :
"Warning: Cannot modify header information - headers already sent by (output started at /home.10.2/strixlab/www/contact2.php:10) in /home.10.2/strixlab/www/contact2.php on line 96"
2 / Quand la page est rechargée (formulaire valide ou non), la page chargée n'est pas http://www.strix.fr/contact2.php?lang=fr mais http://www.strix.fr/contact2.php
[Résolu] 3 / Si le formulaire est valide, la redirection vers /sondmerci.php?lang=XX ne se fait pas.
Je pense que c'est trois erreur sont liées car quand je ne mets pas
Code:
1 2 3 4 5 6
| $insertGoTo = "http://www.strix.fr/sondmerci.php?lang=$lang";
// if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
// $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
// $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
// }
header(sprintf("Location: %s", $insertGoTo)); |
aucune n'erreur apparait (mais bien sûr la redirection non plus).
Voilà, donc si vous aviez une petite idée...
Ah oui j'ai un cookie qui se créé à partir de mes pages concernant la partie multilingue. Je ne le mets pas mais si vous pensez que ça peut-être ça, je le rajouterai.
Merci d'avance