SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    there is no box baztorres's Avatar
    Join Date
    May 2004
    Location
    UK - London \ Surrey
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question formatting form data

    Hello,

    When using the post action for submitting a form, is there a way which the data that I receive in the e-mail can be formatted for easier reading?

    Thanks for any answers in advance.

    Baz

  2. #2
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Depends. Do you have control over the server-side script that receives your post and formats it?

  3. #3
    there is no box baztorres's Avatar
    Join Date
    May 2004
    Location
    UK - London \ Surrey
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not know to be honest what I can show you is the code for the form, excuse the formatting:

    <form name="contact" method="post" action="mailto:baztorres@yahoo.co.uk">
    <p><h4 align="center">contact us</h4>
    <p>
    type of message (please choose one)br>
    <select name="title" size="1">
    <option selected>
    <option>contact</option>
    <option>information</option>
    <option>sales</option>
    </select>

    <p>namebr>
    <input name="name" type="text" id="name">

    <p>e-mailbr>
    <input name="email" type="text" id="email">

    <p>messagebr>
    <textarea cols="40" rows="6" name="message" id="message"></textarea>

    <p>
    <input type="submit">
    <input type="reset">
    </p>
    </form>

  4. #4
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are aware that the thing you do will not mail the contents of the form. It will if your browser supports it open up a "compose new message" in the email client that it (the browser) finds appropriate. If the user has choosen to use Thunderbird or some other email client and surfs with IE, then IE will open Outlook Express (or Outlook) with the mail address you have supplied in the To field. Itīs not untill the user choose send that the message will be sent.
    Is it this you want?

  5. #5
    there is no box baztorres's Avatar
    Join Date
    May 2004
    Location
    UK - London \ Surrey
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I have just tested what it does in and it does not open a new e-mail message to mail off. I am using wXP (at the moment) with MSIE 6.
    What it does do though is display a message with with the contents of:

    This form is being submitted using e-mail.
    Submitting this form will reveal your e-mail address to the recipient,
    and will send the form data without encrypting it for privacy.

    Continue?

    Then I receive an e-mail with an attatchment that can be opened in notepad that has all the data in one stream. Can't provide a copy of the file as I am at work and cannot get to my e-mail.

    What I want is an e-mail to be sent with the data that is filled in in the form to be formatted in the e-mail rather in on a continous unreadable line.
    So it shows

    Subject: Subject title
    Name: Baz
    E-mail: baztorres@yahoo.co.uk
    Message: Message here

    Is there another way that I can then do this?
    Baz
    ---

  6. #6
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Hi,

    If your host supports PHP you can use this script. It's a bit more secure because the spam spiders will not see your email address in the code.
    PHP Code:
    <?php

    $email 
    $_POST['toemail'];
    $MailToAddress "baztorres@yahoo.co.uk"// your email address
    $redirectURL "thankyou.html"// the URL of the thank you page.

    # optional settings
    $MailSubject "[Message from the Contact Page]"// the subject of the message you will receive
    $MailToCC ""// CC (carbon copy) also send the email to this address (leave empty if you don't use it)
    $Message "";
        if (!
    is_array($HTTP_POST_VARS))
        return;
    reset($HTTP_POST_VARS);
        while(list(
    $key$val) = each($HTTP_POST_VARS)) {
            
    $GLOBALS[$key] = $val;
            if (
    is_array($val)) { 
                
    $Message .= "<b>$key:</b> ";
                foreach (
    $val as $vala) { 
                    
    $vala =stripslashes($vala);
                    
    $Message .= "$vala, ";
                } 
                
    $Message .= "<br>";
            }     
            else {
                
    $val stripslashes($val);
                if ((
    $key == "Submit") || ($key == "submit")) { }     
                else {     if (
    $val == "") { $Message .= "$key: - <br>"; }
                        else { 
    $Message .= "<b>$key:</b> $val<br>"; }
                }
            }
        } 
    // end while
    $Message "<font face=verdana size=2>".$Message;
    mail$MailToAddress$MailSubject$Message"Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email."\r\nBCc: ".$MailToCC);
    header("Location: ".$redirectURL);
    ?>
    Save it as whatever.php and point the form action to it.

    I believe you can format the data through some programming in the form processor script like the one above. You will need to post a question in the php forum if you need detailed assistance from the gurus.

  7. #7
    there is no box baztorres's Avatar
    Join Date
    May 2004
    Location
    UK - London \ Surrey
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent , thanks very much.
    The is a starting point to learn php
    Gonna give it a go and post in the php forum with any questions.

    Thanks again
    Baz
    ---


Bookmarks

Posting Permissions

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