Help with my HTML contact form please

17 replies
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 = 'example@mail.com'; $asunto = 'Email title'; mail($para, $asunto, utf8_decode($mensaje), $header); echo 'Message sent correctly'; ?>
#contact #form #html
  • Profile picture of the author teetot
    Before you fix your email script you should probably learn PHP security.
    {{ DiscussionBoard.errors[8224512].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by teetot View Post

      Before you fix your email script you should probably learn PHP security.
      sorry not familiar to php at all as you can see
      just looking for some help
      cheers
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8225654].message }}
      • Profile picture of the author David Beroff
        Originally Posted by watsonovedades View Post

        sorry not familiar to php at all as you can see
        just looking for some help
        cheers
        What teetot was trying to suggest is that hackers can take over your server to send out spam on their behalf, using that script. Here's one place you can start reading how to protect yourself on this particular issue; there are plenty of other resources on security.
        Signature
        Put MY voice on YOUR video: AwesomeAmericanAudio.com
        {{ DiscussionBoard.errors[8229097].message }}
  • Profile picture of the author PaidAllDay
    change this part:

    echo 'Message sent correctly';

    to

    header("Location: myOtherPage.php"); die();
    {{ DiscussionBoard.errors[8224569].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by PaidAllDay View Post

      change this part:

      echo 'Message sent correctly';

      to

      header("Location: myOtherPage.php"); die();
      Thanks man i will try
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8225651].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by PaidAllDay View Post

      change this part:

      echo 'Message sent correctly';

      to

      header("Location: myOtherPage.php"); die();
      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
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8226102].message }}
      • Profile picture of the author David Beroff
        Originally Posted by watsonovedades View Post

        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
        It also struck me that there may be some inadvertent output from line 8 that could be tripping you up. I think as little as a blank space or a single blank line would be enough for PHP to determine that the body has started to be delivered, and thus it's too late to modify the headers. That's why you want to output header info as quickly as possible.
        Signature
        Put MY voice on YOUR video: AwesomeAmericanAudio.com
        {{ DiscussionBoard.errors[8240710].message }}
        • Profile picture of the author watsonovedades
          Originally Posted by David Beroff View Post

          It also struck me that there may be some inadvertent output from line 8 that could be tripping you up. I think as little as a blank space or a single blank line would be enough for PHP to determine that the body has started to be delivered, and thus it's too late to modify the headers. That's why you want to output header info as quickly as possible.
          Thank you Sir
          Contact form has been fixed
          all advices were helpful thankyou all
          Signature
          Whatever your mind can conceive and BELIEVE you can achieve
          Follow me on Twitter - @DineroConPc
          I talk about Affiliate Marketing Methods
          {{ DiscussionBoard.errors[8243567].message }}
  • Profile picture of the author Valdor Kiebach
    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">';
    {{ DiscussionBoard.errors[8226177].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by Valdor Kiebach View Post

      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">';
      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?
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8226266].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by Valdor Kiebach View Post

      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">';
      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
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8228679].message }}
      • Profile picture of the author Valdor Kiebach
        Originally Posted by watsonovedades View Post

        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
        Try this
        Code:
        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=http://www.patadeperro.org.mx">';
        {{ DiscussionBoard.errors[8230252].message }}
  • Profile picture of the author webwizdevelop
    You should not use header and echo together for successful message make seperate php page and print message of successfully sent there
    {{ DiscussionBoard.errors[8229395].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by webwizdevelop View Post

      You should not use header and echo together for successful message make seperate php page and print message of successfully sent there
      can you elaborate an example?
      dont know much php really
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8229402].message }}
  • Profile picture of the author Blakos
    Use PHP echo to call a meta tag page refresh to your desired URL.
    {{ DiscussionBoard.errors[8232011].message }}
    • Profile picture of the author watsonovedades
      Originally Posted by Blake Michelutti View Post

      Use PHP echo to call a meta tag page refresh to your desired URL.
      Thanks can you elaborate an example?

      Cheers
      Signature
      Whatever your mind can conceive and BELIEVE you can achieve
      Follow me on Twitter - @DineroConPc
      I talk about Affiliate Marketing Methods
      {{ DiscussionBoard.errors[8232713].message }}
  • Profile picture of the author David Beroff
    Originally Posted by watsonovedades View Post

    Originally Posted by Blake Michelutti View Post

    Use PHP echo to call a meta tag page refresh to your desired URL.
    Thanks can you elaborate an example?
    That's what Valdor is showing you in post #13 above.
    Signature
    Put MY voice on YOUR video: AwesomeAmericanAudio.com
    {{ DiscussionBoard.errors[8232811].message }}

Trending Topics