Page 1 of 1

HTML not being recognized

Posted: Sun Feb 03, 2008 5:24 pm
by sug15
Hey. I just coded this simple email script. I am a beginner to html.
I have 2 problems. The first is that It will not recognize the <br /> as breaks. it just displays them in the email as "</br >". For example, if the user types "Gloss Metal" for a theme name, and then "Harry J" for developer name, and clicks submit, the email will be outputed as "Gloss Metal<br />Harry J".

The second problem is that it is giving me this When I click submit:

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/u/g/sug15/html/sendmail.php:6) in /home/content/s/u/g/sug15/html/sendmail.php on line 19
However, the email is still sent.

Here is the code for my HTML page (index.html):

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Theme Upload</title>
</head>
<body>
<h2>Add your theme to our database
</h2>
<form method="post" action="sendmail.php">
  <p>Your Email:
  <br> 
    <input name="email" type="text" />
  </p>
  <p>
  Theme's name:
  <br />
    <input name="tname" type="text" size="35" />
  </p>
  <p>Developer's name:    
    <br>
    <input name="dname" type="text" size="35" />
    </p>
    <p>Theme's description:
      <br>
      <textarea name="desciption" cols="45" rows="3"></textarea>
    </p>
      <p>Screenshot link 1:    
    <br>
    <input name="ss1" type="text" size="40" />
  <p>Screenshot link 2:    
    <br>
    <input name="ss2" type="text" size="40" />
    </p>
    <p>Screenshot link 3:    
    <br>
    <input name="ss3" type="text" size="40" />
    
    <blockquote>
      <p>
        <input type="submit" /> 
         <input name="" type="reset" value="Reset" />
        </p>
    </blockquote>
</form>
 
</body>
</html>
Here is the code for my PHP page:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
 
<p>
  <?php
  $email = $_REQUEST['email'] ;
  $tname = $_REQUEST['tname'] ;
  $dname = $_REQUEST['dname'] ;
  $description = $_REQUEST['description'] ;
  $ss1 = $_REQUEST['ss1'] ;
  $ss2 = $_REQUEST['ss2'] ;
  $ss3 = $_REQUEST['ss3'] ;
  $return = ("<br />");
  $message = $tname . $return . $dname . $return . $description . $return . $ss1 . $return . $ss2 . $return . $ss3;
 
  mail( "12345@email.com", "Theme",
    $message, "From: $email" );
  header( "Location: http://website.com/thanks.html" );
?>
 
</body>
</html>
And the thanks.html is just a simple html page.

Help, please.

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 6:10 pm
by Christopher
If you output any characters then PHP will send its current headers and then those characters. So you can have not output before you call the header() function. Just do:

Code: Select all

<?php
  $email = $_REQUEST['email'] ;
  $tname = $_REQUEST['tname'] ;
  $dname = $_REQUEST['dname'] ;
  $description = $_REQUEST['description'] ;
  $ss1 = $_REQUEST['ss1'] ;
  $ss2 = $_REQUEST['ss2'] ;
  $ss3 = $_REQUEST['ss3'] ;
  $return = ("<br />");
  $message = $tname . $return . $dname . $return . $description . $return . $ss1 . $return . $ss2 . $return . $ss3;
 
  mail( "12345@email.com", "Theme",
    $message, "From: $email" );
  header( "Location: http://website.com/thanks.html" );

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 6:34 pm
by sug15
Thanks.

But how can I fix the </ br> problem?

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 7:09 pm
by maliskoleather
you should be using

Code: Select all

$return = "\n";

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 7:31 pm
by sug15
Ok, now I'm getting this:

Code: Select all

Parse error: syntax error, unexpected T_STRING on line 12
Here is the updated php:

Code: Select all

<?php
  $email = $_REQUEST['email'] ;
  $tname = $_REQUEST['tname'] ;
  $dname = $_REQUEST['dname'] ;
  $description = $_REQUEST['description'] ;
  $ss1 = $_REQUEST['ss1'] ;
  $ss2 = $_REQUEST['ss2'] ;
  $ss3 = $_REQUEST['ss3'] ;
  $return = "\n";
  $message = $tname . $return . $dname . $return . $description . $return . $ss1 . $return . $ss2 . $return . $ss3
  
  mail( "name@example.com", "Theme",
    $message, "From: $email" );
  header( "Location: http://website.com/thanks.html" );
?>
 
Thanks. you guys have been a great help so far.

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 7:47 pm
by califdon
<br /> is an HTML tag. Unless you send email with a MIME header (and even then, with some email systems), HTML won't be recognized in an email.

Try this:

Code: Select all

$message = "$tname \r\n $dname \r\n $description \r\n $ss1 \r\n $ss2 \r\n $ss3";

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 7:48 pm
by Jonah Bron
You could also change the headers of the email, and send an HTML email

http://www.google.com/search?sourceid=n ... html+email

Re: HTML not being recognized

Posted: Sun Feb 03, 2008 8:00 pm
by sug15
Thanks, everyone.

It's working perfectly, now :)