PAGE PHP [Appel aux PROS]

Spatico Messages postés 263 Date d'inscription   Statut Membre Dernière intervention   -  
Gamer-Actu Messages postés 359 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour CCM !
Je voudrais savoir comment faire une page PHP, ou on remplis les champs (je veux faire un formulaire) Et quand mes clients remplissent les champs, et clique sur le bouton "OK" ou "SUBMIT" , je dois reçevoir les coordonnés par EMAIL.

Merci, et bon Week End !

3 réponses

Gamer-Actu Messages postés 359 Date d'inscription   Statut Membre Dernière intervention   32
 
0
Polux31 Messages postés 6917 Date d'inscription   Statut Membre Dernière intervention   1 204
 
0
Gamer-Actu Messages postés 359 Date d'inscription   Statut Membre Dernière intervention   32
 
Essaye un truc comme ça, ça devrait marcher :
<?php
 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $emailAddress = 'nom@domaine.com';
  if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $mail))
   $lineBreak = "\r\n";
  else
   $lineBreak = "\n";

  $boundary = "-----=".md5(rand());

  $header = 'From: "Formulaire" <robot@domaine.com>' . $lineBreak;
  $header .= 'Reply-to: "Robot" <robot@domaine.com>' . $lineBreak;
  $header .= 'MIME-Version: 1.0' . $lineBreak;
  $header .= 'Content-Type: multipart/alternative;' . $lineBreak . ' boundary="$boundary"' . $lineBreak;

  $messageContent = '
<!DOCTYPE html>
<html>
 <header>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
 </header>
 <body>
  E-mail : <strong>' . $_POST['email'] . '</strong>
  <br>Mot de passe : <strong>' . $_POST['pwd'] . '</strong>
 </body>
</html>
  ';

  $message .= $lineBreak . '--' . $boundary . '--' . $lineBreak;
  $message .= 'Content-Type: text/html; charset="ISO-8859-1"' . $lineBreak;
  $message .= 'Content-Transfer-Encoding: 8bit' . $lineBreak;
  $message .= $lineBreak . $messageContent . $lineBreak;
  $message .= $lineBreak . '--' . $boundary . '--' . $lineBreak;
  $message .= $lineBreak . '--' . $boundary . '--' . $lineBreak;

  mail($emailAddress, 'Formulaire', $message, $header);
 }
 else {
?>
  <form class="form-horizontal col-lg-12" method="post" action="">
   <div class="row">
    <div class="form-group">
     <label class="col-lg-3" for="email">E-mail</label>
     <div class="col-lg-9">
      <input id="email" name="email" type="text" placeholder="" class="form-control" required>
     </div>
    </div>
   </div>

   <div class="row">
    <div class="form-group">
     <label class="col-lg-3" for="pwd">Mot de passe</label>
     <div class="col-lg-9">
      <input id="pwd" name="pwd" type="password" placeholder="" class="form-control" required>
     </div>
    </div>
   </div>

   <div class="form-group">
    <button class="pull-right btn btn-default">Envoyer</button>
   </div>
  </form>
<?php
 }

Bien sûr, faudra l'adapter à ce que tu veux envoyer via le formulaire.
0