Form will not work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charisma
    New Member
    • Dec 2013
    • 2

    Form will not work

    I found a form that I would like to use. But all so like to add more fields. As it is now. When I click on send. it doesn't work. Can someone help me please.

    This is what I have now.

    [z{link to commercial site redacted - see faq}]

    Sorry, my mistake.

    This is the .php file. The submit button doesn't work.


    Code:
    <?php
    $field_name = $_POST['cf_name'];
    $field_email = $_POST['cf_email'];
    $field_message = $_POST['cf_message'];
    
    $mail_to = 'dedalusonline@yahoo.com';
    $subject = 'Message from a site visitor '.$field_name;
    
    $body_message = 'From: '.$field_name."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'Message: '.$field_message;
    
    $headers = 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";
    
    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    
    if ($mail_status) { ?>
    	<script language="javascript" type="text/javascript">
    		alert('Thank you for the message. We will contact you shortly.');
    		window.location = 'contact_page.html';
    	</script>
    <?php
    }
    else { ?>
    	<script language="javascript" type="text/javascript">
    		alert('Message failed. Please, send an email to louis@charismacommunications.ca');
    		window.location = 'contact_page.html';
    	</script>
    <?php
    }
    ?>
    here is the form HTML
    Code:
    <form action="contact.php" method="post">
    	Your name<br>
        <input type="text" name="cf_name"><br>
    	Your e-mail<br>
        <input type="text" name="cf_email"><br>
    	Message<br>
        <textarea name="cf_message"></textarea><br>
    	<input type="submit" value="Send">
    	<input type="reset" value="Clear">
    </form>
    Last edited by Niheel; Dec 16 '13, 02:54 AM. Reason: In the future, please take the time to write a proper question with all the details.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    "When I click on send. it doesn't work."
    BTW, what is the problem?
    What does not work?
    Why do you think it does something that you do not want it to do?
    What does it doe that you did not expect it to do?

    When clicking 'Send' the data is posted to 'contact.php', which redirect to a non-existing page [z{link to commercial site redacted - see faq}]
    Last edited by zmbd; Dec 15 '13, 11:08 PM. Reason: [z{link to commercial site redacted - see faq}]

    Comment

    • charisma
      New Member
      • Dec 2013
      • 2

      #3
      It doesn't send me an email.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        PHP’s mail() function only passes the mail to the OS’s mail handler executable. whether you receive the email or not is of no concern to mail().

        for "proper" email sending I recommend a mailing library like SwiftMailer.

        Comment

        Working...