Erreur envoi formulaire, page 403

Fermé
xtozez Messages postés 4 Date d'inscription lundi 26 mars 2012 Statut Membre Dernière intervention 27 mars 2012 - 26 mars 2012 à 22:25
xtozez Messages postés 4 Date d'inscription lundi 26 mars 2012 Statut Membre Dernière intervention 27 mars 2012 - 27 mars 2012 à 23:38
Bonjour,

je suis en train de créer un formulaire en html pour mon site, jusque la rien de spécial, sauf que lorsque je test mon formulaire il ne me redirige pas vers la page principale de mon site comme indiquer dans mon code php et je ne reçois pas d'email non plus.

Je pense que ça viens de mon code php car je suis allé au plus simple.

J'ai essayé de regarder sur le forum si je trouvait une solution mais à chaque fois que je pense que j'ai trouvé c'est le même scénario.

voici mon formulaire html :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contact</title>
<style type="text/css">
<!--
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
}
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
color: #6E6C64;
text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
}

/* ~~ this fixed width container surrounds the other divs ~~ */
.container {
width: 960px;
background: #FFF;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
}

/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
background: #FFF;
}

/* ~~ This is the layout information. ~~

1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.

*/

.content {

padding: 10px 0;
background: #92BEE3;
}

/* ~~ The footer ~~ */
.footer {
padding: 10px 0;
background: #FFF;
}

/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style></head>

<body>

<div class="header">
<div class="header"><a href="#"><center> <img src="logo Cap Futura fin sans fond.jpg" width="409" height="92" alt="" />
<!-- end .header --></div>
<div class="content">
<p><center> Contact</p>
<form method="post" action="traitement.php">

<label for="nom">Nom</label> : <input type="text" name="nom" id="nom" required/>
</p>


<label for="prénom">Prénom</label> : <input type="text" name="prénom" id="prénom" required/>
</p>


<label for="E-mail">@ E-mail</label> : <input type="email" placeholder="Ex : contact@cap-futura.com" required/>
</p>


<label for="Tel">Tel </label> : <input type="tel" size="20" maxlength="20" required/>
</p>

<p>
<label for="demande">Votre demande concerne :</label><br />
<select name="demande" id="demande">
<option value="vente">Une vente</option>
<option value="achat">Un achat</option>
<option value="Offre">Une offre de location</option>
<option value="location">Une demande de location</option>
<option value="saison">Une location saisonnière</option>
</select>
</p>

<p>
<label for="message">Votre message </label> : <br />
<textarea name="message" id="message" rows="10" cols="50"></textarea>
</p>

<input type="submit" value="Envoyer" />
</form>

</div>
<div class="footer">
<p>Footer</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>


et voici mon code php :

<?php
$TO = "cap-futura@cap-futura.com";

$h = "From: " . $TO;

$message = "";

while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}

mail($TO, $subject, $message, $h);

Header("Location: www.cap-futura.fr");

?>


Merci d'avance pour vos réponses.


A voir également:

2 réponses

Bonsoir,
Et la variable $subject est initialisée où dans ton script ?
Puis teste la valeur de retour de la fonction mail() et corrige le paramètre de la fonction header() comme ceci : header("location: http://www.cap-futura.fr")
0
xtozez Messages postés 4 Date d'inscription lundi 26 mars 2012 Statut Membre Dernière intervention 27 mars 2012
27 mars 2012 à 17:22
en faisant les modifications comme tu me dis il ne se passe rien de mieux, c'est toujours la même chose quand je test envoyé je tombe sur erreur 403.
0
xtozez Messages postés 4 Date d'inscription lundi 26 mars 2012 Statut Membre Dernière intervention 27 mars 2012
27 mars 2012 à 18:22
j'ai essayé de modifier mon code php, voila ce que ça donne :

<?php

//On récupère les données

$demande = $_POST["demande"]; //On récupère le service que le client souhaite contacter
$nom = $_POST["nom"]; //On récupère le nom ...
$prenom = $_POST["prénom"];
$tel = $_POST["tel"];
$email = $_POST["email"];
$message = $_POST["message"]; //Le message du client



$headers = 'From: "Nom""prénom" <'.$email.'>'."\n";
$headers .='Reply-To: cap-futura@cap-futura.com'."\n"; // Ici l'adresse de réponse
$headers .='Content-Type: text/html; charset="contact"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';


//Maintenant on rempli le mail avec la variable $message :)

$message ='<html>';
$message .='<head></head><body>';
$message .="<p>Informations concernant le prospect<br />";
$message .="Adresse mail de l'expediteur: <b>".$email."</b><br />";
$message .="Nom: <b>".$nom."</b><br />";
$message .="Prenom: <b>".$prénom."</b><br />";
$message .="Téléphone: <b>".$tel."</b><br />";
$message .="<center>---------------------------------------</center><br />";
$message .= $contenu."</p>"; // Ici le message du client
$message .= "</body></html>";

//On envoi le message. N'oubliez pas de changer votreadresse@jenesaispas.fr ;)

if(mail('cap-futura@cap-futura.com', $subject, $message, $headers))

{
echo 'Nous accusons bonne réception de votre message.';
}
else
{
echo 'Erreur! Le message n\'a pu être envoyé';
}

Header("Location: http://www.cap-futura.fr");
?>

mais toujours la même chose!
0
Une erreur 403 signifie que tu n'as pas les permissions sur les dossiers et fichiers que tu utilises pour envoyer le mail. Vérifies les permissions à l'aide de ton FTP pour chaque dossier/fichier impliqué dans l'envoi du mail, depuis ton formulaire jusqu'au fichier de script PHP.
Vérifies également qu'il n'y a pas un fichier .htaccess qui protège l'accès à ces dossiers/fichiers...
0
xtozez Messages postés 4 Date d'inscription lundi 26 mars 2012 Statut Membre Dernière intervention 27 mars 2012
27 mars 2012 à 23:38
j'ai un fichier .htacces dans le fichier logs, mais je n'arrive pas à le supprimer. comment puis-je le contourner?
0