Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Like Tree4Likes

Thread: submit button not working properly

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Member #
    39622

    Cool submit button not working properly

    Hi I'm new to this site and to web design for that matter.

    I have created a website and I have everything working properly except the submit button on the contact us page. The function I want it o do is, when a user finishes completing the form and clicks the submit button. I want it to send an email with the information form the form to send to the assigned email. It doesn't do this, nothing sends, I get the thank you page to appear, but no emails are ever sent. Can anyone help?
    here's the link: Contact Teeny traveling Farm

    Thanks in advanced

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    There is another script that is needed.
    I see you are calling it: sendmail.php

    Can you post that script so I can see it?

    "sendmail.php" is the PHP script that actually sends the email.


  4. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Member #
    39622
    Thank you so much, here it is:


    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "maxnlilnate@me.com", "Feedback Form Results",
    $message, "From: $email" );




    header( "Location: http://www.totallyteenyfarm.com/thankyou.html" );
    ?>

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    The problem isn't the form. The problem is the from value, which you're using as the email someone submitted.

    The code is technically correct, but the problem is deeper than that. Most hosts won't let you send off a script-based email (such as a contact form) from an email address that doesn't already exist on the server. What you'll need to do is create an email address (e.g. formsubmission@totallyteenyfarm.com on your server) and use that as your from email address. This is behavior by design on the part of your host...it protects them from being held liable if someone decides to send spam emails from fake email addresses or email addresses that they don't have access to. .So you can't do what it is that you're trying to do...at least not in the way you want to do it.

    There is still a way to do what you want, however. If you want to reply to the email, you'll need to define a Reply-To header in the email. See example #2 in the link below.

    PHP: mail - Manual
    Maxnlilnate likes this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    Game is right about the webhost limitations on email address used as the sender. But not all webhosts have that rule.

    Just for kicks ... try the script below.
    The difference is the script has to finish the email function before the redirect takes place.
    It's possible there might be a timeout issue happening. It won't hurt anything to try it.

    And note: You have so many things NOT in your script that should be there ... validation and security issues, but that's not part of this discussion.

    <?php
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    if(!mail( "maxnlilnate@me.com", "Feedback Form Results", $message, "From: $email" )){
    echo "email failed to send.";
    }

    header( "Location: http://www.totallyteenyfarm.com/thankyou.html" );
    ?>
    TheGAME1264 and Maxnlilnate like this.


  7. #6
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Member #
    39622
    Thank you both, so after browsing codes I have found, this code under TheGame 1264 link to PHP:mail Maual example # 3 will send the email to my mailbox.
    but what do I need to do to change it and make it use my fields (name, email,phone, and message) instead of just sending the email with this as the message
    Line 1
    Line 2
    Line 3

    I got the subject field correct, and the thank you page to work correctly after it sends. Thank you both so much, you have really been a big help!

    So here's the link that sends the email to my mailbox. How to add name, email, phone and my message fields to this code to make it work correctly.


    <?php

    // The message
    $message = "Line 1\r\nLine 2\r\nLine 3";

    // Send
    mail('maxnlilnate@me.com', 'Questions From Your Website', $message);


    header( "Location: http://www.totallyteenyfarm.com/thankyou.html" );
    ?>
    Last edited by Maxnlilnate; Jul 20th, 2014 at 06:41 AM.

  8. #7
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Change this:
    PHP Code:
    $message "Line 1\r\nLine 2\r\nLine 3"
    to this:
    PHP Code:
    $message $_POST['message'] ; 
    Last edited by Ronald Roe; Jul 21st, 2014 at 07:13 AM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  9. #8
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    @Maxnlilnate

    I put this on my browser address bar and entered it ...

    totally TEENY traveling farm you get this email, it was because I did the entire thing using the URL.

    If you got the email, this is an example of how easily scripts can be manipulated without using good security, validation, or proper PHP commands.

    I know you're just beginning at PHP. I just wanted to demonstrate that for you so you can experience it.


  10. #9
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Quote Originally Posted by mlseim View Post
    If you got the email, this is an example of how easily scripts can be manipulated without using good security, validation, or proper PHP commands.
    And with that, I fixed, or at least believe I did, my code in my previous post. When I put it there, I just copied it from his original post, which used $_REQUEST.
    Maxnlilnate likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  11. #10
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Member #
    39622
    Yah it works! Your awesome, thanks so much


    But for the other fields, they don't work yet. The name, email and phone number. How do I add those to send in the email?

    Also, The security and validation your talking about, what do I need to do for that?


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:14 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com