Menu

how to email php form results in html format?

Help
Anonymous
2004-07-13
2013-06-03
  • Anonymous

    Anonymous - 2004-07-13

    How do i make the submision results display in html For example the form asks for their name so they enter john when i get the email results i get the following in the same black text.
    Name:John
    How can i get the form results sent to me in html? Example
    Name:John "The word Name: in black and the word john in red or bold etc..

     
    • Musawir Ali

      Musawir Ali - 2004-07-15

      you'll need to edit the process.php file that is generated for the form. If you scroll right to the end of that file, you can format the output over there.

       
    • C M

      C M - 2004-08-11

      what would the formatting be, Musawir?

       
    • C M

      C M - 2004-08-24

      Dean007 - and any future users looking for this answer (god knows I wish someone had posted it before me)... after a whole lot of playing around, I came up with the following solution...

      In your final process.php file, adjust the following:

      $message=" $your varliables"
      ";

      To this:

      $message="
      <HTML>
      <HEAD></HEAD>
      <BODY>YOUR MSG HERE</BODY>
      </HTML>
      ";
      //set up the mail
      //
      // Define the recipient.
      $recipient = "RECIPIENTS@ADDRESS.COM";
      //
      // Define the subject line
      $subject = "WHATEVER_SUBJECT_LINE_YOU_WANT";
      //
      // Specify who you want email to come from.
      $mailheaders = "From: WHATEVERYOUWANT \n";
      // The following headers set the format to HTML
      $mailheaders .= "Content-Type: text/html; charset=iso-8859-1\n";
      //
      // This creates and sends the email.
      mail($recipient, $subject, $message, $mailheaders);
      header("Refresh: 0;url=conf.html");
      }
      ?>

      You can pretty well copy and paste this from/over the $message variable to the end of the file. Then edit to include your specifics.

      That said, only catch.. in your HTML work, you cannot use any quotation marks (") .. you must use apostrophe's for everything ('), Otherwise it interupts the PHP process to soon (thinks $message has ended, and it hangs...

      Please feel free to contact me if this isnt clear, of ir you need assistance.

       
      • N Ward

        N Ward - 2008-03-14

        At which line of the processor.php does this get added or simply replace the contents of procesor.php?

         
      • N Ward

        N Ward - 2008-03-14

        I am new to php but here is what I tried and I am getting parse errors.  This for your help on this...

        <?php

        $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

        // Checkbox handling
        $field_7_opts = $_POST['field_7'][0].",". $_POST['field_7'][1].",". $_POST['field_7'][2].",". $_POST['field_7'][3].",". $_POST['field_7'][4];

        mail("you@yourDomain.com","New Employee Request","Form data:

        First Name: " . $_POST['field_1'] . "
        Middle Name (if Any): " . $_POST['field_2'] . "
        Last Name: " . $_POST['field_3'] . "
        Start date: " . $_POST['field_4'] . "
        Computer Requirements: " . $_POST['field_5'] . "
        Communications Requirements: " . $_POST['field_6'] . "
        Company: $field_7_opts
        Telephone set type: " . $_POST['field_8'] . "
        Telephone Line Type: " . $_POST['field_9'] . "

        powered by phpFormGenerator.
        ");

        include("confirm.html");

        $message="$field_7_opts = $_POST['field_7'][0].,. $_POST['field_7'][1].,. $_POST['field_7'][2].,. $_POST['field_7'][3].,. $_POST['field_7'][4]";

        To this:

        $message="
        <HTML>
        <HEAD></HEAD>
        <BODY>YOUR MSG HERE</BODY>
        </HTML>
        ";
        //set up the mail
        //
        // Define the recipient.
        $recipient = "you@yourDomain.com";
        //
        // Define the subject line
        $subject = "New Employee Request";
        //
        // Specify who you want email to come from.
        $mailheaders = "From: me@myDomain.com \n";
        // The following headers set the format to HTML
        $mailheaders .= "Content-Type: text/html; charset=iso-8859-1\n";
        //
        // This creates and sends the email.
        mail($recipient, $subject, $message, $mailheaders);
        header("Refresh: 0;url=confirm.html");
        }

        ?>

         
        • TNTEverett

          TNTEverett - 2008-03-15

          Try this change.

          $message=$field_7_opts = $_POST['field_7'][0].",". $_POST['field_7'][1].",". $_POST['field_7'][2].",". $_POST['field_7'][3].",". $_POST['field_7'][4];

           
    • W4Designs

      W4Designs - 2008-08-24

      Hey, this works like a champ, except for one thing. When I receive it, the from line shows what I replaced WHATEVERYOUWANT in the $mailheaders area as "WHATEVERYOUWANT@mywebhostingmailserver.net"

      Previously, I had the from line working by using the following:

      $headers='From: Web Form Submission <myemail@mydomain.com';

      mail("myemail@mydomain.com","You have a form submission",$message,$headers);

      Anybody have an idea how I can incorporate my function into the one above?

      Thanks!

       
      • TNTEverett

        TNTEverett - 2008-08-24

        I'm not sure what you are asking for.  You don't have a function that I can see. 
        Your $headers syntax needs a little cleanup as well. 
        I suggest you review some php email examples. 

         
    • W4Designs

      W4Designs - 2008-08-24

      Well, I want to use the code fomr the 4th post down to return an HTML email, with a custom "From" entry in the code so maybe it displays my name and has my email embedded as the reply-to email address.

      prior to using the code in teh 4th post down in a NON-html email, just the format the Beta 3.09 produces, I changes the coding from something I found from some posts on the forum here.

      This is what I was using that coded the "From" in the email that was received perfectly:

      $headers='From: My Name <nyemail@mydomain.com';
      $message=
      "
      [all of my fields were inserted here]
      ";

      mail("myemail@mydomain.com","My Desired Subject",$message,$headers);

      So, what I need to know is how to modofy what was in the 4th post so it will produce the same thing as my old mail() function did as far as the "From" portion is concerned.

      I hope that made sense.

      Thanks for your help!
      Buster

       
      • TNTEverett

        TNTEverett - 2008-08-25

        Every time a post is made the number of posts change so referring to the 4th post is meaningless.  I have no idea what you are referring to.

        You must be precise otherwise you will have many issues and unexpected behaviors in your code.
        Your $headers variable does not contain accurate email address syntax according to RFC2821. 
        My Name <nyemail@mydomain.com
        Needs to change to
        My Name <nyemail@mydomain.com>
        According to the RFC example:
        User Name <local-part@domain>

        Without th eclosing ">" the email address will contain everything until it finds the next ">". 

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.