Web Analytics Made Easy -
StatCounter form action, what's the best bid - CodingForum

Announcement

Collapse
No announcement yet.

form action, what's the best bid

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • form action, what's the best bid

    I'm making a form for a friend, and she wants the replies be e-mailed to her. I used:

    <form method="POST" action="mailto:[email protected]?body=" encrypt="text/plain">

    But when the form is sent, the response is not in the body of the e-mail, but attached as a .ATT file. Is there a way to make the reply appear in the body of the e-mail?

    Is there any other ways to go about submitting this form, other than mailto action(i realized that if the person submitting the form doesn't have outlook account set up, it may cause a problem)?

  • #2
    Hi, welcome to the forums.

    To do what you are asking the best method is to use some form of server-side program that will take what the user inputs and send it in an e-mail. This will allow the information to be sent regardless of whether the user has outlook or not, and it will also get sent as the body of the e-mail.

    You may want to look into PHP, ASP or CGI.

    If you dont have these enabled there isnt really any other way.

    Matt
    PHP Weekly - A PHP Developers Resource
    PHP 5.1.4 and Ruby on Rails web hosting
    Moderator of PHP and Work offers and Requests
    Install Apache/PHP/MySQL
    (by marek_mar) | TinyPlugin Architecture

    Comment


    • #3
      I kind of suspected that......I have PHP enabled, I also have a PHP book (i'm a beginner), I tried to look for code that might do something like that, but couldn't find anything, the closest it gets is making form using php functions, but doesn't have anything on how to send the submitted info to an e-mail address. Do you have any suggestions of resources where I can find examples like that? Thanks.

      kat.

      Comment


      • #4
        You need to use php's mail() function to send mail. See: http://us2.php.net/manual/en/function.mail.php

        I personally it like better than using CDONTS in ASP. However the easiest mail implementation I've used is in, I hate to say, ColdFusion. Not that it really matters a whole bunch.
        OracleGuy

        Comment


        • #5
          Luckily for you im a PHP programmer

          This topic has been covered many times, but here it is again:

          Say you have this form:

          Code:
          <p>
          <form action="email.php" method="post">
          Name: <input type="text" name="name" /><br />
          Email: <input type="text" name="mail" /><br />
          <input type="submit" value="Send" />
          </form>
          </p>
          Of course, you could add more fields but this is an example. As you can see the action of the form is "email.php", so this is what email.php should contain:

          PHP Code:
          <?php

          $emailmessage 
          'A new registration on your site\r\n\r\n';

          /* This part here, called a foreach loop, will automatically
              get all the post data sent in the form and make it into
              a nice format for the e-mail */

          foreach($_POST as $key => $value){
              
          $emailmessage .= $key ": "$value "\r\n";
          }

          $emailmessage '\r\nEnd of Email\r\n";

          $to = "[email protected]";
          $subject = "New Registration";
          $headers = "From: [email][email protected][/email]\r\n";

          if(mail($to, $subject, $emailmessage, $headers)){
             echo "Mail Was Sent";
          } else {
             echo "Mail Was No Sent";
          }

          ?>
          Ok, a few explanations:

          You can alter the e-mail message and the email addresses, subject ect.

          \r\n is basically a newline

          the foreach loop part will seem a bit confusing if you are new to programming. Basically, what it does, is it takes all the form data ($_POST) data, and makes it into the form of:

          input name : user inputted value


          Lets say I am a user and I put in the name Matt and the email [email protected]. When I submit the form, email.php will make an email that looks like:

          --------------
          A new registration on your site

          name: Matt
          email: [email protected]

          End of Email

          ---------------


          This may seem very daunting, but have a go and if you have any problems post back here and we can help out. This was the first thing i really tried in php
          PHP Weekly - A PHP Developers Resource
          PHP 5.1.4 and Ruby on Rails web hosting
          Moderator of PHP and Work offers and Requests
          Install Apache/PHP/MySQL
          (by marek_mar) | TinyPlugin Architecture

          Comment


          • #6
            wow....thanks matt, it's exactly what I was looking for. Thanks again, i'm going to go try it out now..... i'll be back with the result.

            Comment


            • #7
              well, ok, here's the deal, the e-mail part is working, and I'm getting the message, but the only that shows in it is "End of Email". Here's what I have for the code:

              PHP Code:
              <?php

              $emailmessage 
              "A new registration on your site\r\n\r\n";


              foreach(
              $_POST as $key => $value){
                  
              $emailmessage .= $name ": "$value "\r\n";
              }

              $emailmessage "\r\nEnd of Email\r\n";

              $to "[email protected]";
              $subject "New Registration";
              $headers = [email]reg@site.org[/email];

              if(
              mail($to$subject$emailmessage$headers)){
                 echo 
              "Form Was Sent";
              } else {
                 echo 
              "Form Was No Sent";
              }

              ?>
              i figured out a way to add all of the field names into the e-mail body, and it works nicely, but it's a lengthy code, I would really like to make this one work, for the future forms where I might have 50 or more fields.

              Thanks
              Last edited by kaattis; Feb 22, 2004, 12:45 AM.

              Comment


              • #8
                Can you post the html for the form?
                OracleGuy

                Comment


                • #9
                  $emailmessage .= "\r\nEnd of Email\r\n";

                  There was a missing . before the =

                  Comment


                  • #10
                    Thanks

                    It worked, thank you i actually learnt something today!!!!!!!!!

                    Comment


                    • #11
                      cheers nightfire missed that one and im glad I could help out.

                      i figured out a way to add all of the field names into the e-mail body, and it works nicely, but it's a lengthy code, I would really like to make this one work, for the future forms where I might have 50 or more fields.
                      the foreach() loop part should do this, was it not working becuase of my missing . on the = sign, or are you still using the large ammount of code?
                      PHP Weekly - A PHP Developers Resource
                      PHP 5.1.4 and Ruby on Rails web hosting
                      Moderator of PHP and Work offers and Requests
                      Install Apache/PHP/MySQL
                      (by marek_mar) | TinyPlugin Architecture

                      Comment


                      • #12
                        it wasn't working because of the missing dot

                        I'm using your code now, well, modified a little and corrected syntax thanks....

                        Comment


                        • #13
                          heheh. Im terrible when it comes to posting on CF, theres always obvious mistakes that i never see in my code. Glad you got it working
                          PHP Weekly - A PHP Developers Resource
                          PHP 5.1.4 and Ruby on Rails web hosting
                          Moderator of PHP and Work offers and Requests
                          Install Apache/PHP/MySQL
                          (by marek_mar) | TinyPlugin Architecture

                          Comment

                          Working...
                          X