Announcement

Collapse
No announcement yet.

php mail function

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

  • php mail function

    exactly how is this done to submit a form with a submit button? I am wanting the user to click the submit button, the results get e-mail to an e-mail addy and the user gets direction to another page Thank you page

  • #2
    There are many formmail php scripts available at www.hotscripts.com, is this what you're after?

    Comment


    • #3
      no I need to know how to use the mail() function in a php page.

      Comment


      • #4
        www.php.net/mail

        www.google.com -> how to use php mail function ?

        Comment


        • #5
          I tried this straight from the php manual and it didn't work
          PHP Code:
          mail("my e-mail addy""My Subject"); 


          Originally posted by merk
          www.php.net/mail

          www.google.com -> how to use php mail function ?

          Comment


          • #6
            You need to add one last parameter: The message. Here:

            PHP Code:
            mail("e-mail address to send the email to""subject""message"); 

            Comment


            • #7
              Here is what I am trying to do the following form submits and I need the results e-mailed to me and the user directed to a Thank You page
              PHP Code:
              <form action="mail ("e-mail address","Hosting")"method="post" enctype="text/html" name="form1" target="_self">
              <
              p>Username
                                                  <
              input type="text" name="textfield">
              </
              p>
                                               <
              p>
                                                  
              Password
                                                   <
              input type="password" name="textfield2"
                                               </
              p>
                                               <
              p>
                                                  
              E-Mail Address
                                                   <
              input type="text" name="textfield3"
                                               </
              p>
                                               <
              p>
                                                  <
              input type="submit" name="Submit" value="Submit"
                                                  <
              input name="Reset" type="reset" id="Reset" value="Reset">                             
                                                  </
              p>
                      </
              form></td>
                   </
              tr


              Originally posted by Silverwolf
              You need to add one last parameter: The message. Here:

              PHP Code:
              mail("e-mail address to send the email to""subject""message"); 

              Comment


              • #8
                I already see a problem with your HTML.

                Code:
                <form action="mail.php";
                I really recomend you use a premade mail script - it seems you dont really know much about the PHP side of things. www.hotscripts.com will have many scripts that match what you are trying to do.

                Comment


                • #9
                  I don't have a mail.php file in the directory at all though

                  Comment


                  • #10
                    Then make one Put this in a file, and change the form action to mail.php, as merk pointed out:

                    PHP Code:
                    <?php

                    if ($_POST[act] == 'mail')
                    {
                         
                    mail("Your email address""Hosting""Someone applied for hosting.  Here's their info:\n\nUsername: $_POST[textfield]\nPassword: $_POST[textfield2]\nEmail address: $_POST[textfield3]");
                         
                    header("location: http://www.yoursite.com/file");
                    }

                    ?>
                    I put the if ($_POST[act] == 'mail') in there so people won't abuse the mail.php script. Stick this:

                    Code:
                    <input type="hidden" name="act" value="mail">
                    ...right before <input type="submit" name="Submit" value="Submit">, and you'll be set to go

                    Comment


                    • #11
                      for some reason that didn't work man this is getting hard but none of the premade scripts I have found will do what I need them to do

                      Comment


                      • #12
                        Then your server probably requires the fifth parameter. Change this:

                        PHP Code:
                        mail("Your email address""Hosting""Someone applied for hosting.  Here's their info:\n\nUsername: $_POST[textfield]\nPassword: $_POST[textfield2]\nEmail address: $_POST[textfield3]"); 
                        To this...

                        PHP Code:
                        mail("Your email address""Hosting""Someone applied for hosting.  Here's their info:\n\nUsername: $_POST[textfield]\nPassword: $_POST[textfield2]\nEmail address: $_POST[textfield3]""From: $_POST[textfield3]""-f your email address"); 
                        Make sure the three textboxes in the form are called "textfield", "textfield 2" and "textfield3", respectively. Also, make sure you put that <input type="hidden" name="act" value="mail"> in there.
                        Last edited by Silverwolf; Thu 30th Oct '03, 9:08pm.

                        Comment


                        • #13
                          That didn't work neither oh well maybe It just can't be done within the page I am trying to do.

                          Comment


                          • #14
                            PHP Code:
                             <form action="<?php mail ("e-mail address","Hosting")"; ?> method="post" enctype="text/html" name="form1" target="_self">
                            <p>Username: 
                                                                <input type="
                            text" name="textfield">
                            </p>
                                                             <p>
                                                                Password: 
                                                                 <input type="
                            password" name="textfield2"> 
                                                             </p>
                                                             <p>
                                                                E-Mail Address: 
                                                                 <input type="
                            text" name="textfield3"> 
                                                             </p>
                                                             <p>
                                                                <input type="
                            submit" name="Submit" value="Submit"> 
                                                                <input name="
                            Reset" type="reset" id="Reset" value="Reset">                             
                                                                </p>
                                    </form></td>
                                 </tr>
                            Maybe that? I dunno...
                            all I did was add <?php ?> tags around the mail() function in the action...

                            Comment


                            • #15
                              its fixed I got it working

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X