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 :

Comment revenir à la page d'accueil ?


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 62
    Points : 30
    Points
    30
    Par défaut Comment revenir à la page d'accueil ?
    Bonsoir,

    Je n'arrive pas à faire revenir sur ma page d'accueil apres avoir validé le bouton envoyer. Quelqu'un pourrait m'aider ? Merci d'avance.

    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    <?php
    //init des variables 
    if (!isset($HTTP_POST_VARS['BSubmit'])) $HTTP_POST_VARS['BSubmit']="";
    if (!isset($erreurlog)) $erreurlog=0;
    ?>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
     
    <link href="blstyle.css" rel="stylesheet" type="text/css">
    </head>
    <body class="sub">
    <form name="form1" method="post" action="">
      <div align="left"></div>
      <table width="81%" border="0" cellpadding="8">
          <tr> 
            <td colspan="3" class="HeaderColor">          <h4 align="center"><span style="mso-bidi-font-size: 12.0pt"><span class="MF_Style_2"><font color="#007FFF" face="Comic Sans MS" size="3">Formulaire d'inscription</font></span></span></h4></td>
          </tr>
          <tr style="vertical-align: top"> 
            <td width="23%" nowrap class="LabelColor" style="text-align: right"><label for="username" class="Texte">
              Nom et Pr&eacute;nom </label></td>
            <td class="TitleColor">          <input name="CNom" type="text" class="Texte_Gras" id="IdNom" value="Nom" size="30"></td>
            <td class="TitleColor"><input name="CPrenom" type="text" class="Texte_Gras" id="IdPrenom" value="Pr&eacute;nom" size="30"></td>
          </tr>
          <tr style="vertical-align: top"> 
            <td style="text-align: right" class="LabelColor"><label for="password" class="Texte">
              Adresse 1 </label></td>
            <td colspan="2" class="TitleColor">  <input name="CAddr1" type="text" class="Texte_Gras" id="IdAddr1" value="Adresse 1&egrave;re partie" size="70"></td>
          </tr>
          <tr style="vertical-align: top"> 
            <td style="text-align: right" class="LabelColor"><label for="confirmpassword" class="Texte">
              Adresse 2 </label></td>
            <td colspan="2" class="TitleColor">  <input name="CAddr2" type="text" class="Texte_Gras" id="IdAddr2" value="Adresse 2&egrave;me partie" size="70">          </td>
          </tr>
          <tr style="vertical-align: top"> 
            <td style="text-align: right" class="Texte">
              Code Postal et Ville </td>
            <td width="31%" class="TitleColor">  <label for="first"></label>   <input name="CCode"  type="text" class="Texte_Gras" id="IdCode" value="Code" size="5" maxlength="5">          </td>
            <td width="46%" class="TitleColor">  <label for="last"></label>    <input name="CVille" type="text" class="Texte_Gras" id="IdVille" value="Ville" size="30">          </td>
          </tr>
          <tr style="vertical-align: top"> 
            <td style="text-align: right" class="LabelColor"><label for="email" class="Texte">
              Email</label></td>
            <td colspan="2" class="TitleColor">  <input name="CEmail" type="text" class="Texte_Gras" id="IdEmail" value="Email" size="50">          </td>
          </tr>
          <tr style="vertical-align: top"> 
            <td style="text-align: right" class="Texte">
              Civilit&eacute;</td>
            <td colspan="2">          <p class="Texte"> 
              <label for="monsieur">Monsieur</label><input name="RBMrMmeMelle" type="radio" id="monsieur" value="Monsieur" checked>
              <label for="madame"> Madame</label><input name="RBMrMmeMelle" type="radio" id="madame"  value="Madame">
              <label for="mademoiselle"> Mademoiselle </label><input name="RBMrMmeMelle" type="radio" id="mademoiselle"  value="Mademoiselle">
    </p></td>
          </tr>
          <tr style="vertical-align: top"> 
            <td colspan="3">            <pre class="Texte">Versement d'acompte :    Oui <input name="RBOuiNon" type="radio" id="yes1"  value="Oui" checked>        N<label for="no1">on</label><input type="radio" id="no1" name="RBOuiNon" value="Non">    </pre>          </td>
          </tr>
     
        <tr style="vertical-align: top" class="FooterColor"> 
          <td colspan="3"><div align="center">
            <input name="BSubmit" type="submit" class="Texte_Gras" id="BSubmit" value="Envoyer">
          </div></td>
        </tr>
      </table>
    </form>
             <?php 
    		 if ($HTTP_POST_VARS['BSubmit']=="Envoyer") {
    			$whbh_mail_to="gcharniere@yahoo.fr";
    			$whbh_mail_text = $_POST['RBMrMmeMelle'] . " " . $_POST['CNom'] . " " . $_POST['CPrenom'] . "\n" .
    			$_POST['CAddr1'] . "\n" .
    			$_POST['CAddr2'] . "\n" .
    			$_POST['CCode'] . " " . $_POST['CVille'] . "\n"  .
    			$_POST['CEmail'] . "\n" ;
    			$whbh_mail_reply= "xxxxx@reply.com";
    			$whbh_mail_from="gcharniere@yahoo.fr";
    			$whbh_mail_sujet= "Demande d'inscription"; 
    			$whbh_date = date("D, j M Y H:i:s -0600"); 	// avec offset horaire
     
    			$entetemail  = "From: $whbh_mail_from \n"; 	// Adresse expéditeur
    			$entetemail .= "Cc: \n";  			// Carbon Copy
    			$entetemail .= "Bcc: \n"; 			// Copies cachées
    			$entetemail .= "Reply-To: $whbh_mail_from \n";  // Adresse de retour
    			$entetemail .= "X-Mailer: PHP/" . phpversion() . "\n" ;
    			$entetemail .= "Date: $whbh_date"; 
    			mail($whbh_mail_to, $whbh_mail_sujet, $whbh_mail_text, $entetemail);
    			}
    		  ?>
    </body>
    </html>

  2. #2
    Membre émérite
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Points : 2 969
    Points
    2 969
    Par défaut
    Salut, à ta place, je mettrais la partie de code PHP tout au début de ta page (avant <html>) et après l'appel de la fonction mail je mettrais
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    header('Location: mapage.php');
    Bon développement
    Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

    F.A.Q. : Java, PHP, (X)HTML / CSS

    N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème

  3. #3
    Membre chevronné
    Avatar de ska_root
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2005
    Messages
    1 203
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Service public

    Informations forums :
    Inscription : Août 2005
    Messages : 1 203
    Points : 1 839
    Points
    1 839
    Par défaut
    Citation Envoyé par Nesmontou
    Salut, à ta place, je mettrais la partie de code PHP tout au début de ta page (avant <html>) et après l'appel de la fonction mail je mettrais
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    header('Location: mapage.php');
    +1

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 62
    Points : 30
    Points
    30
    Par défaut
    Je n'arrive pas à cerner l'endroit

    Est ce apres mail

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    mail($whbh_mail_to, $whbh_mail_sujet, $whbh_mail_text, $entetemail);
    			}
    		  ?>
    </body>
     
    ICI ?????????
    </html>

  5. #5
    Membre régulier
    Inscrit en
    Novembre 2005
    Messages
    114
    Détails du profil
    Informations forums :
    Inscription : Novembre 2005
    Messages : 114
    Points : 72
    Points
    72
    Par défaut
    avant le body

  6. #6
    Membre chevronné
    Avatar de ska_root
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2005
    Messages
    1 203
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Service public

    Informations forums :
    Inscription : Août 2005
    Messages : 1 203
    Points : 1 839
    Points
    1 839
    Par défaut
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
     
    <?php
    //init des variables
    if (!isset($HTTP_POST_VARS['BSubmit'])) $HTTP_POST_VARS['BSubmit']="";
    if (!isset($erreurlog)) $erreurlog=0;
     
           if ($HTTP_POST_VARS['BSubmit']=="Envoyer") {
             $whbh_mail_to="gcharniere@yahoo.fr";
             $whbh_mail_text = $_POST['RBMrMmeMelle'] . " " . $_POST['CNom'] . " " . $_POST['CPrenom'] . "\n" .
             $_POST['CAddr1'] . "\n" .
             $_POST['CAddr2'] . "\n" .
             $_POST['CCode'] . " " . $_POST['CVille'] . "\n"  .
             $_POST['CEmail'] . "\n" ;
             $whbh_mail_reply= "xxxxx@reply.com";
             $whbh_mail_from="gcharniere@yahoo.fr";
             $whbh_mail_sujet= "Demande d'inscription";
             $whbh_date = date("D, j M Y H:i:s -0600");    // avec offset horaire
     
             $entetemail  = "From: $whbh_mail_from \n";    // Adresse expéditeur
             $entetemail .= "Cc: \n";           // Carbon Copy
             $entetemail .= "Bcc: \n";          // Copies cachées
             $entetemail .= "Reply-To: $whbh_mail_from \n";  // Adresse de retour
             $entetemail .= "X-Mailer: PHP/" . phpversion() . "\n" ;
             $entetemail .= "Date: $whbh_date";
             mail($whbh_mail_to, $whbh_mail_sujet, $whbh_mail_text, $entetemail);
             // la redirection
             header("location: accueil.php");
             exit();
             }
     
    ?>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
     
    <link href="blstyle.css" rel="stylesheet" type="text/css">
    </head>
    <body class="sub">
    <form name="form1" method="post" action="">
      <div align="left"></div>
      <table width="81%" border="0" cellpadding="8">
          <tr>
            <td colspan="3" class="HeaderColor">          <h4 align="center"><span style="mso-bidi-font-size: 12.0pt"><span class="MF_Style_2"><font color="#007FFF" face="Comic Sans MS" size="3">Formulaire d'inscription</font></span></span></h4></td>
          </tr>
          <tr style="vertical-align: top">
            <td width="23%" nowrap class="LabelColor" style="text-align: right"><label for="username" class="Texte">
              Nom et Pr&eacute;nom </label></td>
            <td class="TitleColor">          <input name="CNom" type="text" class="Texte_Gras" id="IdNom" value="Nom" size="30"></td>
            <td class="TitleColor"><input name="CPrenom" type="text" class="Texte_Gras" id="IdPrenom" value="Pr&eacute;nom" size="30"></td>
          </tr>
          <tr style="vertical-align: top">
            <td style="text-align: right" class="LabelColor"><label for="password" class="Texte">
              Adresse 1 </label></td>
            <td colspan="2" class="TitleColor">  <input name="CAddr1" type="text" class="Texte_Gras" id="IdAddr1" value="Adresse 1&egrave;re partie" size="70"></td>
          </tr>
          <tr style="vertical-align: top">
            <td style="text-align: right" class="LabelColor"><label for="confirmpassword" class="Texte">
              Adresse 2 </label></td>
            <td colspan="2" class="TitleColor">  <input name="CAddr2" type="text" class="Texte_Gras" id="IdAddr2" value="Adresse 2&egrave;me partie" size="70">          </td>
          </tr>
          <tr style="vertical-align: top">
            <td style="text-align: right" class="Texte">
              Code Postal et Ville </td>
            <td width="31%" class="TitleColor">  <label for="first"></label>   <input name="CCode"  type="text" class="Texte_Gras" id="IdCode" value="Code" size="5" maxlength="5">          </td>
            <td width="46%" class="TitleColor">  <label for="last"></label>    <input name="CVille" type="text" class="Texte_Gras" id="IdVille" value="Ville" size="30">          </td>
          </tr>
          <tr style="vertical-align: top">
            <td style="text-align: right" class="LabelColor"><label for="email" class="Texte">
              Email</label></td>
            <td colspan="2" class="TitleColor">  <input name="CEmail" type="text" class="Texte_Gras" id="IdEmail" value="Email" size="50">          </td>
          </tr>
          <tr style="vertical-align: top">
            <td style="text-align: right" class="Texte">
              Civilit&eacute;</td>
            <td colspan="2">          <p class="Texte">
              <label for="monsieur">Monsieur</label><input name="RBMrMmeMelle" type="radio" id="monsieur" value="Monsieur" checked>
              <label for="madame"> Madame</label><input name="RBMrMmeMelle" type="radio" id="madame"  value="Madame">
              <label for="mademoiselle"> Mademoiselle </label><input name="RBMrMmeMelle" type="radio" id="mademoiselle"  value="Mademoiselle">
    </p></td>
          </tr>
          <tr style="vertical-align: top">
            <td colspan="3">            <pre class="Texte">Versement d'acompte :    Oui <input name="RBOuiNon" type="radio" id="yes1"  value="Oui" checked>        N<label for="no1">on</label><input type="radio" id="no1" name="RBOuiNon" value="Non">    </pre>          </td>
          </tr>
     
        <tr style="vertical-align: top" class="FooterColor">
          <td colspan="3"><div align="center">
            <input name="BSubmit" type="submit" class="Texte_Gras" id="BSubmit" value="Envoyer">
          </div></td>
        </tr>
      </table>
    </form>
    </body>
    </html>

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 62
    Points : 30
    Points
    30
    Par défaut
    au test, ça m'a sorti une page d'erreur

    Je voulais rajouter un test
    lorsque le champ nom et prenom sont vides, envoyer un message d'erreur pour champs obligatoires
    je crois qu'il faut utiliser les post c'est là que cela complique

    comment programme t-on cela ?

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 62
    Points : 30
    Points
    30
    Par défaut
    Cela a fonctionné avec les doubles quotes

    Comment faire si l'on veut ajouter quelques de controle de validité des champs ? merci. vous etes vraiment des pros !!!!

  9. #9
    Membre chevronné
    Avatar de ska_root
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2005
    Messages
    1 203
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Service public

    Informations forums :
    Inscription : Août 2005
    Messages : 1 203
    Points : 1 839
    Points
    1 839
    Par défaut
    et bien tu as juste a tester les valeurs des superglobales, et ne pas envoyer l'email si vides !

    un exemple :

    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
     
    // declaration du message d'erreur :
    $msg = '';
     
    // si la superglobale "nom" n'existe pas on l'initialise avec une chaine vide
    $nom = (!isset($_POST['nom']))?(''):($_POST['nom']);
     
    // si chaine vide
    if(empty($nom)) {
     
       $msg = "le champs nom est obligatoire !";
     
    // sinon
    }else {
     
       // envoi de l'email
     
    }
    .............
    echo $msg;

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 62
    Points : 30
    Points
    30
    Par défaut
    Je dois faire ce test apres la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    if ($HTTP_POST_VARS['BSubmit']=="Envoyer")
    N'est ce pas ?

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 62
    Points : 30
    Points
    30
    Par défaut
    Cela fait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    if ($HTTP_POST_VARS['BSubmit']=="Envoyer") {
       if (empty($nom)) { 
           $msg = "le champs nom est obligatoire !"; 
          }
       else { 
     
       // envoi de l'email 
     
       } 
    }
    echo $msg;
    Merci de me dire si cela est exact ou pas

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

Discussions similaires

  1. [Spip] Comment afficher une page d'accueil ?
    Par Gigi95 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 4
    Dernier message: 17/10/2007, 12h15
  2. Comment revenir à la page précédente en cliquant sur un lien
    Par veevee dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 21/04/2007, 19h29
  3. Comment changer la page d'accueil de Tomcat?
    Par khokho dans le forum Tomcat et TomEE
    Réponses: 2
    Dernier message: 13/01/2007, 01h59

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