Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: HTML in forms

  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML in forms

    okay so i have a form located @ http://bigfooty.hacksawed.com/email.html

    this form basically gets data and posts it to another page called submit.php

    submit.php then emails our email at hacksawed@gmail.com

    the problem is, i want to allow it to send html rather than text, and for that html to be displayed accordingly (like a website) in our email account.

    the code for email.html is:

    Code:
    <!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=iso-8859-1" />
    <title>Anonymous Email Sender</title>
    </head>
    
    <body>
    <form id="form1" name="form1" method="post" action="submit.php">
      <label>Subject:
      <input type="text" name="textfield" />
      </label>
      <p>
        <label>Message
        <textarea name="textarea" cols="100" rows="20"></textarea>
        </label>
      </p>
      <p>
        <label>
        <input type="submit" name="Submit" value="Submit" />
        </label>
      </p>
    </form>
    </body>
    </html>
    The code for submit.php is:

    Code:
    <?php
    # ----------------------------------------------------
    # -----
    # ----- This script was generated by the demo version of PHP-Form  1.1 on 8/05/2006 at 7:59:15 PM
    # -----
    # ----- http://www.websitedatabases.com
    # -----
    # ----------------------------------------------------
    # -----
    # ----- Many Features are available only in the Full version, to order please follow this link : 
    # -----
    # ----- http:// www.websitedatabases.com/form-form/index.html 
    # -----
    # ----------------------------------------------------
    
    
    // Receiving variables
    @$textfield = addslashes($_POST['textfield']);
    @$textarea = addslashes($_POST['textarea']);
    
    // Validation
    //Sending Email to form owner
    # Email to Owner 
    $pfw_header = "From: bigfooty@gmail.com";
    $pfw_subject = "#textfield#";
    $pfw_email_to = "hacksawed@gmail.com";
    $pfw_message = "$textarea\n";
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
    
    header("Location: login.html");
    
    ?>
    im not sure which file to edit, i think its email.html, but im nto sure.

    can anyoen help???

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Bristol, UK
    Posts
    147
    Thanks
    6
    Thanked 2 Times in 2 Posts
    theres no real difference between text emails and html emails, its just the way the client interprets the text.

    Just add a content type header:

    Code:
    $headers = "Content-type: text/html\r\n";
    Try that..

    Jon
    "You only live once, play it right, and once is enough" - me :)
    "When i die only god can take my soul" - me again! :P

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    unfortunately it didnt work. i added it here:

    $headers = "Content-type: text/html\r\n";
    $pfw_header = "From: bigfooty@gmail.com";
    $pfw_subject = "#textfield#";
    $pfw_email_to = "hacksawed@gmail.com";
    $pfw_message = "$textarea\n";
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

    which code do it add it to, and where in the code do i add it?

    i got it to send the email both to a hotmail account and gmail account, and both spat it out as coding rather than what its sposed to do, and i know that both these email companies do html.

  • #4
    Regular Coder
    Join Date
    May 2006
    Location
    Bristol, UK
    Posts
    147
    Thanks
    6
    Thanked 2 Times in 2 Posts
    theres no use in creating a var unless your going to use it

    Code:
    $headers = "Content-type: text/html\r\n";
    $pfw_header = "From: bigfooty@gmail.com";
    $pfw_subject = "#textfield#";
    $pfw_email_to = "hacksawed@gmail.com";
    $pfw_message = "$textarea\n";
    
    mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header, $headers ) ;
    Try that, see what happens...

    Jon
    "You only live once, play it right, and once is enough" - me :)
    "When i die only god can take my soul" - me again! :P

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think we are on the right track, but the server gives me this error:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Apache/1.3.33 Server at bigfooty.hacksawed.com Port 80
    And I know its not to do with the server, becuase I reedited it back and the email went thru (just obviously with the problem i had before there).

  • #6
    Regular Coder
    Join Date
    May 2006
    Location
    Bristol, UK
    Posts
    147
    Thanks
    6
    Thanked 2 Times in 2 Posts
    This should get you closer, (hopefully), see how you get on with that, add the other bits and pieces you want.

    Code:
    $to = "hacksawed@gmail.com";
    $from = "$_POST['fromfield'];
    $subject = "$_POST['subject'];
    $message = "$_POST['messaqe'];
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    
    mail($to, $subject, $message, $headers);
    Thats all off the top of my head, so may need a bit of work, but should get you closer to your goal!!

    Jon
    "You only live once, play it right, and once is enough" - me :)
    "When i die only god can take my soul" - me again! :P

  • #7
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I then get this problem:

    Code:
    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/h/a/c/hacksawed/html/bigfooty/sub.php on line 25

  • #8
    Regular Coder
    Join Date
    May 2006
    Location
    Bristol, UK
    Posts
    147
    Thanks
    6
    Thanked 2 Times in 2 Posts
    can you copy your whole script?

    that will make it easier.

    Jon

    EDIT/ i dident look above!!
    "You only live once, play it right, and once is enough" - me :)
    "When i die only god can take my soul" - me again! :P

  • #9
    Regular Coder
    Join Date
    May 2006
    Location
    Bristol, UK
    Posts
    147
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Tested and working, just add your email and should be ok....

    Form:
    Code:
    <html>
    <head>
    <title>Email</title>
    <style type="text/css">
    
    </style>
    </head>
    <body>
    
    <form name="mail" method="post" action="mail.php">
    
    Your Name:<br>
    	<input type="text" name="name" value="Your name..." size="20"><br>
    	<br>
    Subject: <br>
    
    	<input type="text" name="subject" value="Subject..." size="28"><br>
    	<br>
    
    Comment:<br>
    	<textarea rows="10" cols="25" name="comment"> </textarea><br>
    	<br>
    	<br>
    	<input type="submit" value="Send">
    	<input type="reset" value="Reset">
    </form>
    
    </body>
    </html>
    and mail.php
    PHP Code:
    <?php

       $to
    ="jon@fartingfish.com";
       
    $from=$_POST['name'];
       
    $subject=$_POST['subject'];
       
    $message=$_POST['comment'];
       
    $headers "MIME-Version: 1.0\r\n";
       
    $headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
       
    $headers.= "From: $from\r\n";
       if (
    mail($to$subject$message$headers))
          echo 
    "Message Sent!";
       else
          echo 
    "Failed to send message.";
    ?>
    Jon
    "You only live once, play it right, and once is enough" - me :)
    "When i die only god can take my soul" - me again! :P

  • #10
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    It was brought to my attention that the HTML form needed was actually a fake VBulletin notice designed to phish information from other forum members. Regardless if it was or not, I've decided to delete any threads that followed after that code was introduced, and close this thread.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •