www.webdeveloper.com
Results 1 to 5 of 5

Thread: Submit Button Help

  1. #1
    Join Date
    Sep 2012
    Posts
    2

    Lightbulb Submit Button Help

    Hey, I have a website with a contact form but i am struggling with the 'Submit' side of things. I really need the button to push the information to one of my emails. Please help!

    This is my code (its all on an html page)...

    <form action="#" id="contact-form">
    <fieldset>
    <div class="wrapper">
    <div class="success"> Contact form submitted! <br> <strong class="color-1">We will be in touch soon.</strong> </div>
    </div>
    <div class="field">
    <label class="name">
    <input type="text" value="Name:">
    <span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span>
    </label>
    </div>
    <div class="field">
    <label class="email">
    <input type="text" value="Email:">
    <span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span>
    </label>
    </div>
    <div class="field">
    <label class="phone">
    <input type="tel" value="Phone:">
    <span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span>
    </label>
    </div>
    <div class="area">
    <label class="message">
    <textarea>Message:</textarea>
    <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span>
    </label>
    </div>
    <div class="clear"></div>
    <div class="buttons-wrapper">
    <a href="#" class="button" data-type="reset">Clear</a>
    <a href="#" class="button" data-type="submit">Send</a>
    </div>
    </fieldset>
    </form>

    I was told to add this code to the bottom of it, but it didnt help.

    <?php
    $ToEmail = 'forms@aepi.org.uk';
    $EmailSubject = 'Site Contact Form';
    $mailheader = "From: ".$_POST["email"]."\r\n";
    $mail header .= "Reply-To: ".$_POST["email"]."\r\n";
    $mail header .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $MESSAGE_BODY = "Name: ".$_POST["name"]."";
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."";
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."";
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
    ?>

    Any help will be much appreciated
    Thank you!

  2. #2
    Join Date
    Mar 2012
    Posts
    1,565
    The PHP code requires:
    a) That the "action" points to the same page. I'm not sure if "#" will work, but it might.
    b) That the file extension is ".php" not ".html".
    c) It is run on a server. I.e. You can't run it locally in your browser (as you can html).
    d) You should also add error checking to prevent the "mail" command being triggered inappropriately. As it stands it will trigger an email every time the page is accessed or refreshed!!!

    P.S. Just tested the "#" and it works. I've learned something today
    Last edited by jedaisoul; 09-08-2012 at 06:03 AM.

  3. #3
    Join Date
    Sep 2012
    Posts
    2

    Still not working

    Hi,
    I have tried this on a server already and nothing worked, i also tried changing the page to .php and still nothing

  4. #4
    Join Date
    Mar 2012
    Posts
    1,565
    Are you trying it on a web server, and is php and php mail enabled?

  5. #5
    Join Date
    Apr 2006
    Posts
    66
    The form is an html page, the form action points to a form to mail php processor on your server. If processor is not there nothing happens.

    Many free php form to mail scripts available on line.

    The ones that offer html response and/or attachment capibilities a little shakey.

    See: http:southriverdesign.com/mail/index.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
HTML5 Development Center



Recent Articles