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 :

[Mail] ajouter d'envoyer une page par mail


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 46
    Points : 31
    Points
    31
    Par défaut [Mail] ajouter d'envoyer une page par mail
    Bonjour,

    J'ai deux pages

    une HTML et une PHP

    comment ajouter une fonction dans PHP permettant d'envoyer un mail à une adresse prédéfinie et reprenant le contenu de la page PHP

    Voici le code PHP :

    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
     
     
    <?php
    // Formulaire envoye ? Champs Vides ?
    foreach($_POST as $champs => $valeur) {
    if($champs != 'cartons_vin1' AND $champs != 'cartons_vin2' AND $champs != 'cartons_vin3') {
     if(!isset($valeur) OR empty($valeur)) {
      echo '<script type="text/javascript">// <![CDATA[',"\n",'alert("Veuillez remplir tous les champs.");',"\n",'window.location="form.html";',"\n",'// ]]>',"\n",'</script>';
     }
    }
    }
    // Declaration des variables
    $Nom = trim(strip_tags($_POST['Nom']));
    $Prenom = trim(strip_tags($_POST['Prenom']));
    $Email = trim(strip_tags($_POST['Email']));
    $Adresse = trim(strip_tags($_POST['Adresse']));
    $NbreCartons['vin1'] = trim(strip_tags($_POST['cartons_vin1']));
    $NbreCartons['vin2'] = trim(strip_tags($_POST['cartons_vin2']));
    $NbreCartons['vin3'] = trim(strip_tags($_POST['cartons_vin3']));
    $SousTotal['vin1'] = $NbreCartons['vin1'] * 4.5;
    $SousTotal['vin2'] = $NbreCartons['vin2'] * 4.5;
    $SousTotal['vin3'] = $NbreCartons['vin3'] * 4.5;
    $Total = $SousTotal['vin1'] + $SousTotal['vin2'] + $SousTotal['vin3'];
    ?>
    <?php echo '<','?xml version="1.0" encoding="ISO-8859-1" ?','>',"\n"; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR" dir="ltr">
    <head xml:lang="fr-FR" dir="ltr">
     <title>
      Achat de Cartons de Vin - R&eacute;capitulatif de votre Commande
     </title>
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
     <div id="contenu_principal">
      <h3>R&eacute;capitulatif de vos Informations :</h3>
      <p>Votre Nom :&nbsp;<strong><?php echo $Nom; ?></strong></p>
      <p>Votre Pr&eacute;nom :&nbsp;<strong><?php echo $Prenom; ?></strong></p>
      <p>Votre Adresse Email :&nbsp;<strong><?php echo $Email; ?></strong></p>
      <p>Votre Adresse Postale :&nbsp;<strong><?php echo $Adresse; ?></strong></p>
      <h3>R&eacute;capitulatif de votre Commande</h3>
      <p>Vous avez command&eacute;&nbsp;<?php echo ($NbreCartons['vin1'] == 1) ? "<strong>{$NbreCartons['vin1']}</strong>&nbsp;carton&nbsp;" : "{$NbreCartons['vin1']}&nbsp;cartons&nbsp;"; ?>du vin n°1, soit un total de&nbsp;<strong><?php echo $SousTotal['vin1']; ?></strong>&nbsp;&euro;.</p>
      <p>Vous avez command&eacute;&nbsp;<?php echo ($NbreCartons['vin1'] == 1) ? "<strong>{$NbreCartons['vin2']}</strong>&nbsp;carton&nbsp;" : "{$NbreCartons['vin2']}&nbsp;cartons&nbsp;"; ?>du vin n°2, soit un total de&nbsp;<strong><?php echo $SousTotal['vin2']; ?></strong>&nbsp;&euro;.</p>
      <p>Vous avez command&eacute;&nbsp;<?php echo ($NbreCartons['vin1'] == 1) ? "<strong>{$NbreCartons['vin3']}</strong>&nbsp;carton&nbsp;" : "{$NbreCartons['vin3']}&nbsp;cartons&nbsp;"; ?>du vin n°3, soit un total de&nbsp;<strong><?php echo $SousTotal['vin3']; ?></strong>&nbsp;&euro;.</p>
      <p style="font-weight: bold; color: #c00000;">Le total de votre commande s'&eacute;l&egrave;ve donc à <strong><?php echo $Total; ?></strong> &euro;.</p>
      <p><a href="form.html">Modifier vos Informations</a>&nbsp;|&nbsp;<a href="javascript:print()">Imprimer cette Page</a>
     </div>
    </body>
    </html>
    Merci de m'aider si vous avez besoins d'info supplémentaires merci n'hésitez pas

    Pierre

  2. #2
    Membre éclairé Avatar de grabriel
    Inscrit en
    Septembre 2006
    Messages
    946
    Détails du profil
    Informations forums :
    Inscription : Septembre 2006
    Messages : 946
    Points : 730
    Points
    730
    Par défaut
    salut,

    reprenant le contenu de la page PHP
    Si j'ai bien compris tu veux récupérer les variables saisies dans ton formulaire???

    Si c'est le cas tu peux utiliser la fonction mail (http://fr.php.net/mail) en passant en paramètre ton message que tu auras au préalablement construit.

    Exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    $txtmail=$txtmail."Nom Prenom : ".$nomprenom."\t adresse : ".$adresse;
    $txtmail=$txtmail." \n codeville : ".$codeville." \t pays : ".$pays."\n";
     
    ...
    $email="adresse@du_client.fr";
    $sujet="Votre commande de vin";
    $mail="vendeur_de_vin@piloupilou999.fr";
     
    mail($email,$sujet,$txtmail,"From:".$mail);
    les \t = tabulation et les \n = retour charriot
    c'est pour une mise en page basique.

    [EDIT]Sinon si ton texte à une mise en forme complexe et trop galère à mettre en page comme au dessus tu peux voir du coté des buffer, tu redirige le rendu de ta page dans un buffer que tu mets en variable. La variable obtenue, tu peux l'afficher avec un simple echo et tu peux aussi la mettre en variable à la place de txtmail [/EDIT]

Discussions similaires

  1. [XL-2010] Envoyer une feuille par mail outook
    Par yoyo-tns dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 16/10/2013, 13h21
  2. envoyer une sélection par mail
    Par Yvan41 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 14/10/2009, 14h13
  3. 2.4.2 envoyer une erreur par mail
    Par Benoit_Durand dans le forum Développement de jobs
    Réponses: 1
    Dernier message: 07/01/2009, 11h00
  4. Problème pour envoyer une pj par mail
    Par bobic dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 15/04/2008, 09h07

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