PHP HTML Form mail question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wayne

    PHP HTML Form mail question

    Hi,

    I have recently added tried to update the feedback form on my
    page to be sent in HTML format.

    Problem is that when its submitted, I get the mail without the
    variable input, just the variable name.

    I have added the text version to it and both send fine, but still only
    the text version includes the variable input.

    HTML code taken directly from php.net example (See my form below).

    Can anyone advise how I can solve this ?

    --
    Thanks,

    Wayne

    <?php
    $to = 'webmaster@mydo main.com';
    $subject = 'www.mydomain.c om - contact';
    $message = '
    <html>
    <head>
    <title>www.mydomain.com - contact</title>
    </head>
    <body>
    <br>
    <p>Contact from www.mydomain.co m</p>
    <table>
    <tr><td>Name</td><td>$contact name</td>
    <tr><td>Email address</td><td>$contact emailaddress</td>
    <tr><td>Query </td><td>$contact query</td>
    </table>
    </body>
    </html>
    ';
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'To: Webmaster <webmaster@mydo main.com>' . "\r\n";
    $headers .= 'From: $contactname <$contactemaila ddress>' . "\r\n";
    mail($to, $subject, $message, $headers);
    ?>


  • Andy Jeffries

    #2
    Re: PHP HTML Form mail question

    On Thu, 30 Mar 2006 10:35:32 +0200, Wayne wrote:
    [color=blue]
    > Hi,
    >
    > I have recently added tried to update the feedback form on my page to be
    > sent in HTML format.
    >
    > Problem is that when its submitted, I get the mail without the variable
    > input, just the variable name.
    >
    > I have added the text version to it and both send fine, but still only the
    > text version includes the variable input.
    >
    > HTML code taken directly from php.net example (See my form below).
    >
    > Can anyone advise how I can solve this ?[/color]

    Because you've used single quotes on the line:

    $message = '

    If you wrap a string in single quotes variables are not substituted within
    it. You need to wrap the content for $message in double quotes.

    Cheers,


    Andy

    --
    Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
    http://www.gphpedit.org | PHP editor for Gnome 2
    http://www.andyjeffries.co.uk | Personal site and photos

    Comment

    • elyob

      #3
      Re: PHP HTML Form mail question


      "Andy Jeffries" <news@andyjeffr ies.co.uk> wrote in message
      news:pan.2006.0 3.30.08.56.41.3 98091@andyjeffr ies.co.uk...[color=blue]
      > On Thu, 30 Mar 2006 10:35:32 +0200, Wayne wrote:
      >[color=green]
      >> Hi,
      >>
      >> I have recently added tried to update the feedback form on my page to be
      >> sent in HTML format.
      >>
      >> Problem is that when its submitted, I get the mail without the variable
      >> input, just the variable name.
      >>
      >> I have added the text version to it and both send fine, but still only
      >> the
      >> text version includes the variable input.
      >>
      >> HTML code taken directly from php.net example (See my form below).
      >>
      >> Can anyone advise how I can solve this ?[/color]
      >
      > Because you've used single quotes on the line:
      >
      > $message = '
      >
      > If you wrap a string in single quotes variables are not substituted within
      > it. You need to wrap the content for $message in double quotes.
      >[/color]

      or close the quote, place the variable, continue the quote .. e.g.

      $headers .= 'From: $contactname <'.$contactemai laddress.'>' . "\r\n";

      Although I'm not sure what that list bit on the OP's line is trying to do.


      Comment

      Working...