Les avertissements suivants se sont produits :
Warning [2] Undefined array key 0 - Line: 1640 - File: showthread.php PHP 8.2.18 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 1640 errorHandler->error_callback
/showthread.php 915 buildtree




Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Formulaires de contact
#20
Bonjour Jce Wink

Je déterre ce vieux post...

Je suis en train de tester ton formulaire simple (le vieux formulaire de la version 1.x qui utilise la fonction mail() de PHP). Il fonctionne très bien, aucun souci.

Par contre j'ai voulu rajouter un champs "societe" et là ça coince. Non pas dans le formulaire en lui même, ni dans l'envoi, cela se passe bien. Par contre dans le mail reçu ne figure pas l'information contenue dans le champs "societe".

Je pense que le problème doit se passer au niveau de :
Code :
if (!empty($_POST['societe'])) $societe =($_POST['societe']); // Ajout Soupaloignon

        if (!empty($_POST['name'])) $name =($_POST['name']); // Jce suppress cfSanitize

        if (!empty($_POST['email'])) $email = cfSanitize($_POST['email']);

        if (!empty($_POST['subject'])) $subject = ($_POST['subject']); // Jce suppress cfSanitize

        if (!empty($_POST['message'])) $message = $_POST['message'];



        $bodymessage.= " \r\n";

        $bodymessage = " Societe : ".utf8_decode($societe)."\r\n";    // Ajout Soupaloignon

        $bodymessage = " Prenom et Nom : ".utf8_decode($name)."\r\n";    //Prénom et Nom

        $bodymessage.= " Adresse mail : ".($email)."\r\n\r\n";            

        $bodymessage.= " Message  : \r\n".utf8_decode($message)."\r\n";

        $bodymessage.= " \r\n";

Mais je ne vois pas vraiment où. Peut être au niveau du point qui est après certains $bodymessage ?

Aurais tu une idée ?


Le code complet :
Code :
<?php



# CMSMS - CMS Made Simple

#

# (c)2004 by Ted Kulp (wishy@users.sf.net)

#

# This project's homepage is: [url]http://cmsmadesimple.org[/url]

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation; either version 2 of the License, or

# (at your option) any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

//Révision: 3468+3550+3553+3933

//Modification du 11/11/06  reprise de la version 0.13 +  traduc

// -->+ Ex Modif du 14/09/06 suppression de  cfSanitize( ...  Pour retour à la ligne +++ et ajout de utf8_decode() pour la lecture des mails en iso-8859-1

// TEST sur Free ACRN Attention au code source={contact_form email='xxxx@free.fr' captcha='true'}

//Modiication Rev3550  - 06/12/2006 -->Fix contact form with internal pretty url's

//Modiication Rev 3553 -09/12/2006 ->Fix Undefined index: style and captcha error notice

//Modif rev 3933 10/05/2007- JCE  add sender ip to contact_form message, line 110

// Modificatio du 17/05/2008 ajout    echo lang('help_function_contact_form'); l'aide se trouve maintenet dans le fichier \admin\lang\ext\fr_FR\admin.inc.php



//27/12/2009   Suppresion de <!-- input type="reset" value="Effacer" / --> ajout  $bodymessage pour afficher dans la corps du message les infos

// - last modification 06/01/2009



function smarty_cms_function_contact_form($params, &$smarty) {



// init

    global $gCms;

    $date_serveur = date("Y-m-d H:m:s"); // date du jour



    if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha']))

    {

        $captcha =& $gCms->modules['Captcha']['object'];

    }



    if (empty($params['email'])){

        echo '<div class="formError">Une adresse email doit etre spécifi&eacute;e pour utiliser ce pluging.</div>';

        return;

    }else{

        $to = $params['email'];

    }

    

    $style = true; // Use default styles

    if (FALSE == empty($params['style']) && $params['style'] === "false" ) $style = false; // Except if "false" given in params

    

    $errorsStyle = 'style="font-weight: bold; color: red;"'; // jce

    $OKStyle = 'style="font-weight: bold;"'; // jce

        

    $captchaStyle = 'style="width: 350px; margin-bottom:1em; text-align: center;"'; //jce

        

    $errors=$name=$email=$subject=$message = '';

    $bodymessage = '';

    if (FALSE == empty($params['subject_get_var']) && FALSE == empty($_GET[$params['subject_get_var']]))

      {

        $subject = $_GET[$params['subject_get_var']];

      }

    if($_SERVER['REQUEST_METHOD']=='POST'){

        if (!empty($_POST['societe'])) $societe =($_POST['societe']); // Ajout Soupaloignon

        if (!empty($_POST['name'])) $name =($_POST['name']); // Jce suppress cfSanitize

        if (!empty($_POST['email'])) $email = cfSanitize($_POST['email']);

        if (!empty($_POST['subject'])) $subject = ($_POST['subject']); // Jce suppress cfSanitize

        if (!empty($_POST['message'])) $message = $_POST['message'];



        $bodymessage.= " \r\n";

        $bodymessage = " Societe : ".utf8_decode($societe)."\r\n";    // Ajout Soupaloignon

        $bodymessage = " Prenom et Nom : ".utf8_decode($name)."\r\n";    //Pr&eacute;nom et Nom

        $bodymessage.= " Adresse mail : ".($email)."\r\n\r\n";            

        $bodymessage.= " Message  : \r\n".utf8_decode($message)."\r\n";

        $bodymessage.= " \r\n";



            

        if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha']))

        {

            if (!empty($_POST['captcha_resp'])) { $captcha_resp = $_POST['captcha_resp']; }

        }



        //Mail headers

        //$extra = "From: $name <$email>\r\n";

        $name = utf8_decode($name); // jce    

        $extra = "From: $name <$email>\r\nReply-To: $email\r\n"; //jce

        //$extra .= "Content-Type: text/plain\r\n"; // enlevé car c'est cela qui perturbe le utf8_decode --> utf8/iso

        

        if (empty($societe)) $errors .= "\t\t<li>" . 'Merci d\'indiquer votre societe.' . "</li>\n"; // Ajout Soupaloignon

        if (empty($name)) $errors .= "\t\t<li>" . 'Merci d\'indiquer votre Pr&eacute;nom et Nom.' . "</li>\n";

        if (empty($email)) $errors .= "\t\t<li>" . 'Merci d\'indiquer votre adresse mail.' . "</li>\n";

        elseif (!validEmail($email)) $errors .= "\t\t<li>" . 'Votre adresse mail est non valide.' . "</li>\n";

        if (empty($subject)) $errors .= "\t\t<li>" . 'Merci d\'indiquer votre sujet.' . "</li>\n";

        if (empty($message)) $errors .= "\t\t<li>" . 'Merci de renseigner le texte de votre message.' . "</li>\n";

        if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha']))

        {

            if (empty($captcha_resp)) $errors .= "\t\t<li>" . 'Merci d\'entrer le texte contenu dans l\'image' . "</li>\n";

            elseif (! ($captcha->checkCaptcha($captcha_resp))) $errors .= "\t\t<li>" . 'Le texte contenu dans l\'image n\'est pas correct !' . "</li>\n";

        }

        

        if (!empty($errors)) {

            echo '<div class="formError" ' . (($style) ? $errorsStyle:'') . '>' . "\n";

            //echo '<p>Error(s) : </p>' . "\n";

            echo "\t<ul>\n";

            echo $errors;

            echo "\t</ul>\n";

            echo "</div>";

        }

                                                //, utf8_decode($message) .

        elseif (@mail($to, utf8_decode($subject), ($bodymessage) . "\n\nEmis par ".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]." le : ".$date_serveur." par IP : ".$_SERVER["REMOTE_ADDR"]." Navigateur : ".$_SERVER["HTTP_USER_AGENT"], $extra)) {

            echo '<div class="formMessage"' . (($style) ? $OKStyle:'') . '>Votre message a bien &eacute;t&eacute; envoy&eacute;.</div>' . "\n";    //Jce        

            return;  

        }

        else {

            echo '<div class="formError" ' . (($style) ? $errorsStyle:'') . '>D&eacute;sol&eacute; le message ne peut etre envoy&eacute;, le serveur est hors service ou une erreur interdit l\'envoi !</div>' . "\n";

            return;

        }

    }

//Modiication Rev3550  - 06/12/2006

    if (isset($_SERVER['REQUEST_URI']))

    {

    $action = $_SERVER['REQUEST_URI'];

    }

    else

    {

    $action = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '';

    if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '')

    {

        $action .= '?'.$_SERVER['QUERY_STRING'];

    }

    }



// Form  

    ?>

    <form action="<?php $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'] ?>" method="post" name="contactForm">



    

<label for="societe" title="Veuillez saisir votre societe" <?php echo ($style)?' style="font-weight: bold;"':''; ?>>* Votre societe :</label>

<input type="text" name="societe" id="societe" title="Veuillez saisir votre societe" value="<?php echo htmlspecialchars($name); ?>" size="50"<?php echo ($style)?' style="width: 350px; border: solid 1px navy; display: block; margin-bottom: 7px;margin-top: 7px;"':''; ?> />

    

<label for="name" title="Veuillez saisir votre Pr&eacute;nom et Nom" <?php echo ($style)?' style="font-weight: bold;"':''; ?>>* Votre Pr&eacute;nom et Nom :</label>

<input type="text" name="name" id="name" title="Veuillez saisir votre Pr&eacute;nom et Nom" value="<?php echo htmlspecialchars($name); ?>" size="50"<?php echo ($style)?' style="width: 350px; border: solid 1px navy; display: block; margin-bottom: 7px;margin-top: 7px;"':''; ?> />

    

<label for="email" title="Veuillez saisir votre adresse email" <?php echo ($style)?' style="font-weight: bold;"':''; ?>>* Votre adresse mail :</label>

<input type="text" name="email" id="email" title="Veuillez saisir votre adresse email" value="<?php echo htmlspecialchars($email); ?>" size="50"<?php echo ($style)?' style="width: 350px; border: solid 1px black; display: block; margin-bottom: 7px;margin-top: 7px;"':''; ?> />



<label for="subject" title="Veuillez saisir votre Sujet" <?php echo ($style)?' style="font-weight: bold;"':''; ?>>* Sujet du message :</label>    

<input type="text" name="subject" id="subject" title="Veuillez saisir votre Sujet" value="<?php echo htmlspecialchars($subject); ?>" size="50"<?php echo ($style)?' style="width: 350px; border: solid 1px navy; display: block; margin-bottom: 7px;margin-top: 7px;"':''; ?> />

    

<label for="message" title="Veuillez saisir votre message" <?php echo ($style)?' style="font-weight: bold;"':''; ?>>* Votre message :</label>

<textarea name="message" id="message" title="Veuillez saisir votre message" cols="40" rows="10"<?php echo ($style)?' style="width: 350px; border: solid 1px navy; display: block; margin-bottom: 7px;margin-top: 7px;"':''; ?>><?php echo htmlspecialchars($message); ?></textarea>



<?php

//  captcha

if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha']))

{

?>

<label for="captcha_resp" title="Entrer les caract&egrave;res g&eacute;n&eacute;r&eacute;s par l'image" <?php echo ($style)?' style="font-weight: bold;"':''; ?>>* Entrer les caract&egrave;res g&eacute;n&eacute;r&eacute;s par l'image : </label><br />

<input type="text" name="captcha_resp"  id="captcha_resp" title=" Entrer les caract&egrave;res g&eacute;n&eacute;r&eacute;s par l'image" value="" size="20" <?php echo ($style) ? $captchaStyle:''; ?>/>

<?php

    echo "<div $captchaStyle>" . $captcha->getCaptcha() . '</div>';

}

// End captcha

?>



    <input type="submit" value="Envoyer" /><!-- input type="reset" value="Effacer" / -->

    </form>

<br /><small>* Champs obligatoires</small>



<?php

// End form

}





function smarty_cms_help_function_contact_form() {

  echo lang('help_function_contact_form');

    ?>

    <h3>Ajout Fr</h3>    

    <ul>

        <li>Modification pour envoyer les accents pour la lecture des mails en iso-8859-1.</li>    

        <li>Traduction des termes anglais en fran&ccedil;ais.</li>

    </ul>

    <br />

    <?php

}



function smarty_cms_about_function_contact_form() {

    ?>

    <p>Author: Brett Batie &lt;brett-cms@classicwebdevelopment.com&gt; &amp; Simon van der Linden &lt;ifmy@geekbox.be&gt;</p>

    <p>Version: 1.5 (20091227)</p>

    <p>

    Change History:<br/>

        <ul>

        <li>l.2 : various improvements (errors handling, etc.)</li>

        <li>1.3 : added subject_get_var parameter (by elijahlofgren)</li>

        <li>1.4 : added captcha module support (by Dick Ittmann)</li>

        <li>1.5 : jce7350 modifications</li>

        </ul>

    </p>

    <?php

}





function cfsanitize($content){

    return str_replace(array("\r", "\n"), "", trim($content));

}



function validEmail($email) {

    if (!preg_match("/^([\w|\.|\-|_]+)@([\w||\-|_]+)\.([\w|\.|\-|_]+)$/i", $email)) {

        return false;

        exit;

    }

    return true;

}

// modification JCE Validée le 14/11/06



?>
==> Merci de marquer [Résolu] dans le titre de votre message lorsque une solution a été trouvée <==

Mint 17
Répondre


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)