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 4 of 4

Thread: Web Forms

  1. #1
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Web Forms

    Hello,

    I had a few basic questions regarding web forms. I am building a website for my father's construction business. I know basic html, css, and some javascript/jquery. I am looking to create a form on his "contact us" page that allows a visitor to input their name and phone number for a free estimate. I used php to create the form, and when I enter info into the form and click submit, my mail app pops up and asks me to log in to my e-mail (I'm on a Mac). What I am looking to do is have a form where they can enter some basic information, and submit it to me without actually sending an e-mail from their e-mail address. I am not even sure if php is the easiest way to go about doing this (I'm not even 100% clear on what php is used for exactly), I have heard that you can also create forms using html5. So basically, I need a form that allows a user to enter info, and when they press submit, it just goes to another page that says something like "Thank you for inquiring about a free estimate" without the need to log into an e-mail. I hope this makes sense to somebody.

    Thanks!

    -Mike

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,224
    Thanks
    10
    Thanked 269 Times in 268 Posts
    You're looking for a "php mail script" (google that). The form ACTION needs to point at such a script, which will take the contents of the form, bundle them into an email, and send it off. Right now, your action is a "mailto:" which expects to use a local email client on the user's PC, which is ok at times, but in general not preferable to the script.

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,417
    Thanks
    68
    Thanked 102 Times in 101 Posts
    Here are two simple ones for you to copy and paste. A Nice & Simple Contact Form
    PHP mail() Function


    This is the one I use on my website.

    PHP Code:
    if (isset($_POST['submit105'])) {

              
    $name $_POST['name'];

              
    $email $_POST['email'];
              
    $phone $_POST['phone'];
              
    $comments $_POST['comments'];
              
    $contact $_POST['contact'];

    //define the receiver of the email
    $to 'sales@americanmadesigns.com';
    //define the subject of the email
    $subject 'Customer Inquiry';
    //define the message to be sent. Each line should be separated with \n
    $message "This message was sent from American Made Signs.com. \n\n Name: $name\n Email: $email\n Phone: $phone\n\n Comments: $comments\n\n Contact Method: $contact";
    //define the headers we want passed. Note that they are separated with \r\n
    $headers "From: American Made Signs\r\nReply-To: sales@americanmadesigns.com";
    //send the email
    $mail_sent = @mail$to$subject$message$headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
    echo $mail_sent "<h3>We have successfully received your email. Thank you!</h3>" "A problem occered with sending an email. Please try again.";
    }




    <
    form action="contactus.php" method="post">
                  <
    table width="75%">
              <
    tr><td><b>Name:</b></td><td><input type="text" name="name" size="15" maxlength="30" value=""></td></tr>
              <
    tr><td><b>E-mail:</b></td><td><input type="text" name="email" size="15" maxlength="45" value=""></td></tr>
              <
    tr><td><b>Phone:</b></td><td><input type="text" name="phone" size="15" maxlength="14" value=""></td></tr>
              <
    tr><td><b>Contact Method:</b></td><td><select name="contact">
              <
    option value="Email">Email</option>
              <
    option value="Phone">Phone</option>
              <
    option value="Person">In Person</option>
              </
    select></td>
              </
    table>
              <
    br />
              <
    table width="75%">
              <
    tr><td><b>Question/Comments:</b></td><td><textarea name="comments" cols="25" rows="5"></textarea></td></tr>
              
                     <
    tr><td><input type="submit" name="submit105" value="Send Email"></td></tr
    Last edited by myfayt; 04-24-2014 at 12:52 PM.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #4
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome thanks guys!


  •  

    Tags for 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
    •