SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I want to create a completely customizable mail script where it is like FormMail (http://www.worldwidemart.com/scripts/).

    So basically it will have to automatically get all the Input fields and add them to the message part of the bottom seperate by 2 lines.

    Also, the recipient hidden field would need to be automatically added to the To: section of the mail() command in PHP.

    Lastly, if there is a from, it is added to the From: section of the mail() command.

    I would want PHP to do this within a form name mailForm or something like it so that it doesn't get all the other forms on one pages' information.

    Does anyone know how you would go about doing this?

    Thanx
    Peter

  2. #2
    Idea Developer
    Join Date
    Sep 2000
    Location
    Bethlehem, PA
    Posts
    521
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, use the mail () command

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I mean, how would I search the previous page for all the input tags/names/values/textareas, ect and then display them using the mail()?

    Thanx

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the global $HTTP_POST_VARS array. And loop through it. Some of the values returned by the form are going to be mandatory like mailto address, subject line, sender email, etc - the values you need for your mail function. You can access these directly as long as the user has entered the correct name value for these in their form. The others are going to be unknown at design time (ie, user implimented) but which you will have to format into the message string. So you want to write a conditional if so that only the right key/value pairs get put into the message. Something like:
    PHP Code:

    $message 
    $senderEMail ' submitted the following form data\n\n';

    foreach(
    $HTTP_POST_VARS as $key => $value) {
       if ( 
    $key != "mailto" && $key != "subject" && $key != "senderEmail" ) {
          
    $message .= $key '   ' $value// format the key/value however you want to
          
    $message .= '\n'// new line between each key/value
       
    }
    }
    mail($mailto$subject$message); 
    Note the user has to have global vars turned on for this to work.
    Last edited by freakysid; Apr 9, 2001 at 09:14.


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
  •