Advertisement
Guest User

Untitled

a guest
Jul 13th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2. require_once('recaptchalib.php');
  3. require('funciones.php');
  4. $conexion = conectarBD();
  5. $privkey = "6LdvPiITAAAAAOkQ6LpzWmpQW3kcNtmMQO64Vqm9";
  6. $verify = recaptcha_check_answer($privkey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
  7.  
  8.  
  9. require 'phpmailer/PHPMailerAutoload.php';
  10. $mail = new PHPMailer;
  11. $mail->isSMTP();
  12. $mail->Host = 'smtp.live.com';
  13. $mail->SMTPAuth = true;
  14. $mail->Username = 'prowebutn@hotmail.com';
  15. $mail->Password = 'asereje124';
  16. $mail->SMTPSecure = 'tls';
  17. $mail->Port = 587;
  18. $mail->setFrom($_POST['email']);
  19. $mail->addAddress('prowebutn@hotmail.com');
  20.  
  21. $mail->isHTML(false);
  22.  
  23. $mail->Subject = $_POST['asunto'];
  24. $mail->Body    = "De: " .$_POST['nombre'] ."\n" ."\n" .$_POST['mensaje'];
  25.    
  26.  
  27. if ($verify->is_valid) {
  28.     header("refresh:3;url=contacto.php");
  29.     $nombre = $_POST['nombre'];
  30.     $email = $_POST['email'];
  31.     $msj = $_POST['mensaje'];
  32.     $sql_insert = "insert into mensajes (email, msj, nombre) values ('$email', '$msj', '$nombre')";
  33.     mysqli_query($conexion, $sql_insert);
  34.    
  35.     if(!$mail->send()) {
  36.     echo 'Message could not be sent.';
  37.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  38.     } else {
  39.     echo 'Message sent';
  40. }
  41.  
  42.     die();
  43.    
  44. }else {
  45.     header("refresh:3;url=contacto.php");
  46.     echo "Oops parece que el codigo de verificacion no es correcto. Volviendo a la página anterior.";
  47. }
  48.  
  49.     die();
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement