i have form mail, when submitted i get the reuslts without any format, the code

<form method=post action="<?PHP_SELF?>">
<input type=text name="Name">
<input type=text name="Age">
<input type=submit name="Submit" value="Submit">
</form>

if($Submit)
{
 //This will post all form values
 while (list($key,$value) = each($HTTP_POST_VARS))
 {
 $msg .= "$key: $value\n"; //assigning to msg!
 }
mail("someone@somewhere","Test Subject","$msg\n",
 "me@somewhere.com") or die("mail not functioned!");
 echo "<h2>Thank you</h2><br>Thank you .";
}
else
{
echo "$successMsg";
}//end else Submit
?>

the form does work proper, but the email result im getting not formatted to what i need

so, how can i format it?, i want to capture variables $name and $age and present it nicely. is there a way to format the result in HTML , so that i can present the results in HTML ?

thanks indeeeeeeeeeeed 😕

    is there a way to format the result in HTML

    Yes. Replace your \n's with <br>'s.

    -or-

    Use [man]nl2br/man before you send the email.

      thanks for the reply ..

      but what if want to format the $name variable and type it in Bold format and the $age variable in Italic ... any way out ??? :bemused:

        This was pulled from your code above and modified to get the desired effect.

        while (list($key,$value) = each($HTTP_POST_VARS))
         {
         if($key == "Name"){ $key = "<b>".$key."</b>"; }
         if($key == "Age"){ $key = "<i>".$key."</i>"; }
         $msg .= "$key: $value\n"; //assigning to msg!
         }

        Hope that helps. Just out of curiosity, are you getting the submit variable text "Submit!" included in the email bodies?

          thats awsome :eek:

          Just out of curiosity, are you getting the submit variable text "Submit!" included in the email bodies?

          mmm .. i dont think so! , am i passing it too!

            I dunno. That's why I was asking. I would assume so since your while statment lists ALL POSTED variables, and submit would have also posted.

              it does!

              how do i eliminate it (submit button)

              thanks indeeeeeeeeeeeeeeeed

                Just a point. Unless you are using a very old version, you should be using $_POST not $HTTP_POST_VARS. manual

                  I am not 100% positive, but I am fairly sure that if you put:

                  unset($_POST['Submit']);

                  just after your

                  if($Submit){

                  it should unset it before your while loop reads it.

                    You should also be setting for MIME encoding if you want to send html

                    from the manual

                    / To send HTML mail, you can set the Content-type header. /
                    $headers = "MIME-Version: 1.0\r\n";
                    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

                      thanks in zillions

                      you guys been a great help, without it, my form, would had take some other end :o

                      thanks alloot..

                      it says ""The Knowlede is the only thing that grows when sharing with others

                        Write a Reply...