IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

[Système] Probleme avec la fonction str_replace


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3
    Points : 5
    Points
    5
    Par défaut [Système] Probleme avec la fonction str_replace
    Bonjour à tous !
    J'ai un petit souci concernant des $variables que je fait parvenir par email l'hors de l'inscription à mes services.

    script coté serveur


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    // ------------------------------------------------------
    function confirmation_mail($saField,$rubrique,$id){
    // ------------------------------------------------------
    global $expediteur;
     
    $message = readFileIntoBuffer("../script/email_confirmation.htm");
     
    $message = str_replace("[ID]",$id,$message);
    $message = str_replace("[DATE]",strftime("%d/%m/%Y"),$message);
    $message = str_replace("[TITRE]",$saField[titre],$message);
    $message = str_replace("[NOM]",$saField[nom],$message);
     
    include('../admin/wamailer/class.mailer.php');
     
    $subject = 'accusé de reception';
     
    $mailer = new Mailer();
     
    $mailer->set_from($expediteur, 'monsite.com');
    $mailer->set_address($saField[email]);
     
    $mailer->set_format('html');
    $mailer->set_subject($subject);
    $mailer->set_message($message);
     
    if( !$mailer->send() )
    { 
    	erreur_saisie();
    }else{
    	//echo "un email de confirmation a été envoyé";
    	header("location:../index.php");
    }
     
    }
    mon mail html

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
    <title></title>
    <STYLE>BODY {
    	BACKGROUND-POSITION: left top; MARGIN-TOP: 10px; FONT-SIZE: 10pt; MARGIN-LEFT: 50px; COLOR: #000000; BACKGROUND-REPEAT: no-repeat; FONT-FAMILY: Verdana;
    }
    </STYLE>
     
    <BODY bgColor=#ffffff>
    <p align="left"><strong>Objet : Accus&eacute; de r&eacute;ception N&deg;<font size="2">2006/[ID]</font></strong></p>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr> 
        <td><fieldset>
          <legend><strong> <strong> <span class="verdana15"><strong><span class="verdana15"><strong><span class="verdana15"><strong><strong><span class="verdana15"><strong><span class="verdana15"><strong><span class="verdana15"><strong><span class="verdana15"><strong><img src="/www.recherches-express.com/images/base/arrow-bleu.gif" width="4" height="7" align="absmiddle"></strong></span></strong></span></strong></span></strong></span></strong><span class="verdana15"></span></strong></span> 
          </strong></span></strong></span> <font size="2">Vos informations personnnelles</font></strong></strong></legend>
          <table width="100%" border="0" cellspacing="0" cellpadding="5">
            <tr> 
              <td><div> 
                  <table width="100%" border="0" cellpadding="4" cellspacing="2">
                    <tr> 
                      <td colspan="6" class="verdana11"> <div align="left"> 
                          <p><font size="2">[TITRE] [NOM]</font></p>
                        </div></td>
                    </tr>
                    <tr> 
                      <td colspan="6" class="verdana11"><font size="2">[ADRESSE] [ADRESSE2]</font></td>
                    </tr>
                    <tr> 
                      <td colspan="6" class="verdana11"><font size="2">[CP] [VILLE]</font></td>
                    </tr>
                    <tr> 
                      <td colspan="6" class="verdana11"><font size="2">[TEL]</font> 
                      </td>
                    </tr>
                    <tr> 
                      <td colspan="6" class="verdana11"><font size="2">[FAX]</font> 
                      </td>
                    </tr>
                    <tr> 
                      <td colspan="6"><font size="2">[EMAIL]</font> </td>
                    </tr>
                  </table>
                </div></td>
            </tr>
          </table>
          </fieldset></td>
      </tr>
    </table>
    </BODY></HTML>
    Ma question est :

    Dans mon email (email_confirmation.htm ##### VOIR + HAUT)
    Comment ne rien afficher dans [NOM] si ma variable n'est pas renseignée.

    Merci d'avance pour vos infos

    Tony

  2. #2
    Membre éprouvé Avatar de FCYPBA
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    745
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Novembre 2004
    Messages : 745
    Points : 952
    Points
    952
    Par défaut
    Si la variable n'est pas renseigné, il faudrait qu'elle contienne une chaine vide. Cela résoudriat tes problèmes.

    Sinon il faudra faire des if

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Système] Probleme avec fonction exec:
    Par nacimem dans le forum Langage
    Réponses: 1
    Dernier message: 18/06/2009, 14h36
  2. [Système] probleme avec la fonction ora_exec()
    Par vrossi59 dans le forum Langage
    Réponses: 6
    Dernier message: 25/03/2006, 12h18
  3. [LG] Problème avec la Fonction ReadLn en fin de programme
    Par killermano dans le forum Langage
    Réponses: 6
    Dernier message: 23/07/2005, 15h16
  4. [LG]Probleme avec une fonction
    Par xavier1936 dans le forum Langage
    Réponses: 7
    Dernier message: 08/02/2005, 22h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo