Guest User

Untitled

a guest
Sep 22nd, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <?php
  2. $email = '#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i';
  3. $lettre = '`^([a-zA-Zàáâãäåçèéêëìíîïðòóôõöùúûüýÿ](\-| |\'|)){2,40}$`';
  4.  
  5. require("class.phpmailer.php");
  6.  
  7. if (isset($_POST["txtnom"])) {
  8.  
  9. $mail = new PHPMailer();
  10. //$body = file_get_contents($_POST["messageArea"]);
  11. //$body = eregi_replace("[\]",'',$body);
  12.  
  13. $mail->IsSMTP(); // set mailer to use SMTP
  14. try {
  15. $mail->Host = "smtp.live.com"; // smtp serveur
  16. $mail->SMTPDebug = 2;
  17.  
  18. $mail->SMTPAuth = true;
  19. $mail->Host = "smtp.live.com"; // smtp serveur
  20. $mail->Port = 587;
  21.  
  22. $mail->Username = "psyco78@hotmail.com";
  23. $mail->Password = "frederik78";
  24.  
  25. $mail->AddAddress('psyco78@hotmail.com', 'Admin');
  26. $mail->SetFrom($_POST["txtemail"], $_POST["txtnom"]);
  27.  
  28. $mail->MsgHTML($_POST["messageArea"]);
  29. $mail->SMTPSecure = "tls";
  30. $mail->Send();
  31.  
  32. header("location: index.php?PagePhp=Contacter" );
  33. echo "Message envoyer<p></p>\n";
  34. } catch (phpmailerException $e) {
  35. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  36. } catch (Exception $e) {
  37. echo $e->getMessage(); //Boring error messages from anything else!
  38. }
  39. }
  40. ?>
  41. <html>
  42. <head>
  43. <script type="text/javascript" src="jquery.js"></script>
  44. </head>
  45.  
  46. <body>
  47.  
  48. <div style="color: white; padding-top: 10px;">
  49. <div style="text-align: center; padding-bottom: 20px;">
  50. <h3>
  51. Contact
  52. </h3>
  53. Si vous avez des questions c'est la place pour le demander
  54.  
  55. </div>
  56. <div>
  57. <form method="POST" name="email" onsubmit="return ValidationContanct()">
  58.  
  59. <table align="center" >
  60. <tr>
  61. <td>
  62. <font color="white">Nom :</font>
  63. </td>
  64. <td>
  65. <input type="text" id="txtnom" name="txtnom" onkeypress="return ValidKeyPress(event)" maxlength="40"/>
  66. </td>
  67. <td>
  68. <?php
  69. if (!empty($_POST["txtnom"])) {
  70.  
  71. $_POST["txtnom"] = htmlspecialchars($_POST["txtnom"]);
  72.  
  73. if (!preg_match($lettre, $_POST["txtnom"])) {
  74. echo '<font color="Red">Pas de <strong>Chiffre</strong></font>';
  75. }
  76. }
  77. ?>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td>
  82. <font color="white">Email :</font>
  83. </td>
  84. <td>
  85. <input type="text" ID="txtemail" name="txtemail" maxlength="255"/>
  86. </td>
  87. <td>
  88. <?php
  89. if (!empty($_POST["txtemail"])) {
  90.  
  91. $_POST["txtemail"] = htmlspecialchars($_POST["txtemail"]);
  92.  
  93. if (!preg_match($email, $_POST["txtemail"])) {
  94. echo '<font color="Red">Email non <strong>valide</strong></font>';
  95. }
  96. }
  97. ?>
  98. </td>
  99. </tr>
  100. <tr>
  101. <td colspan="2">
  102. <font color="white">Message:</font>
  103. </td>
  104.  
  105. </tr>
  106. <tr>
  107. <td colspan="2">
  108. <textarea name="messageArea" cols="30" rows="10"></textarea>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td colspan="2" align="right">
  113. <input type="submit" value="Valider"/>
  114. </td>
  115. </tr>
  116.  
  117. </table>
  118. </form>
  119. </div>
  120. </div>
  121. </body>
  122. </html>
Add Comment
Please, Sign In to add comment