Help with my HTML contact form please

by 17 replies
20
Hi i made this php code to send an email to my inbox but when the message its sent it redirects to a blank ugly page with a lame message, i want to redirect to another URL of my choise , can you help do that

here is the code ( i think it gots something todo with the echo t the end maybe? thanks to all

<?php $nombre = $_POST['nombre']; $mail = $_POST['mail']; $empresa = $_POST['empresa']; $header = 'From: ' . $mail . " \r\n"; $header .= "X-Mailer: PHP/" . phpversion() . " \r\n"; $header .= "Mime-Version: 1.0 \r\n"; $header .= "Content-Type: text/plain"; $mensaje = "Este mensaje fue enviado por " . $nombre . ", de la empresa " . $empresa . " \r\n"; $mensaje .= "Su e-mail es: " . $mail . " \r\n"; $mensaje .= "Mensaje: " . $_POST['mensaje'] . " \r\n"; $mensaje .= "Enviado el " . date('d/m/Y', time()); $para = ''; $asunto = ''; mail($para, $asunto, utf8_decode($mensaje), $header); echo 'Message sent correctly'; ?>
#programming #contact #form #html
  • Before you fix your email script you should probably learn PHP security.
    • [ 1 ] Thanks
    • [1] reply
    • sorry not familiar to php at all as you can see
      just looking for some help
      cheers
      • [1] reply
  • change this part:

    echo 'Message sent correctly';

    to

    header("Location: myOtherPage.php"); die();
    • [2] replies
    • Thanks man i will try
    • Hi PaidAllDay

      i got this error msg

      Warning: Cannot modify header information - headers already sent by (output started at /home1/wayseer/public_html/patadeperro.org.mx/contacto/enviar.php:8) in /home1/wayseer/public_html/patadeperro.org.mx/contacto/enviar.php on line 29

      Any suggestions?

      Thanks
      • [1] reply
  • I cant reproduce the error.

    The code you posted doesnt have 29 lines.

    Anyway try replacing:
    echo 'Message sent correctly';
    with this:
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=myOtherPage.php">';
    • [2] replies
    • sorry i dont know how to paste the code correctly the [code] tags dont seem to work,

      thanks for th code i will try it
      can i redirect to my index.html homepage?
    • It seems to work but i get redirected to the same contact form page
      www.mywebsite.com/contact/index.html

      i replaced myOtherPage.php with index.html

      i want to go to the home page after submitting the form

      Thanks so much for the help
      • [1] reply
  • You should not use header and echo together for successful message make seperate php page and print message of successfully sent there
    • [1] reply
    • can you elaborate an example?
      dont know much php really
  • Use PHP echo to call a meta tag page refresh to your desired URL.
    • [1] reply
  • That's what Valdor is showing you in post #13 above.
    • [ 2 ] Thanks

Next Topics on Trending Feed

  • 20

    Hi i made this php code to send an email to my inbox but when the message its sent it redirects to a blank ugly page with a lame message, i want to redirect to another URL of my choise , can you help do that here is the code ( i think it gots something todo with the echo t the end maybe? thanks to all