Results 1 to 2 of 2

Thread: Contact form

  1. #1
    Junior Member
    Join Date
    Oct 2015
    Posts
    1

    Contact form

    Hi,

    I have created a contact form but I cannot seem to get it working.

    Within the html I have this

    HTML Code:
    <form class="form-horizontal" role="form">
              
              
              <div class="form-group">
        
                    <label for="contact-name" class="col-sm-2 control-label">Name</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="contact-name" placeholder="First and Last Name">          
                  </div>
              </div>
                        <div class="form-group">
        
                    <label for="contact-email" class="col-sm-2 control-label">Email</label>
                  <div class="col-sm-10">
                    <input type="email" class="form-control" id="contact-email" placeholder="example@domain.com">          
                  </div>
              </div>
              
                                  <div class="form-group">
        
                    <label for="contact-message" class="col-sm-2 control-label">Message</label>
                  <div class="col-sm-10">
                          <textarea class="form-control" rows="4"></textarea>  
                  </div>
              </div>
        <button type="submit" class="btn btn-primary">Send</button>
              
              
              
    </form>
    then in contact.php I have the following

    PHP Code:
    <?php
        $contact
    -name $_POST['contact-name'];
        
    $contact-email $_POST['contact-email'];
        
    $contact-message $_POST['contact-message'];
        
    $from 'From: TangledDemo'
        
    $to 'andy_alban@outlook.com'
        
    $subject 'Hello';
        
    $human $_POST['human'];
                
        
    $body "From: $name\n E-Mail: $email\n Message:\n $message";
                    
        if (
    $_POST['submit'] && $human == '4') {                 
            if (
    mail ($to$subject$body$from)) { 
            echo 
    '<p>Your message has been sent!</p>';
        } else { 
            echo 
    '<p>Something went wrong, go back and try again!</p>'
        } 
        } else if (
    $_POST['submit'] && $human != '4') {
        echo 
    '<p>You answered the anti-spam question incorrectly!</p>';
        }
    ?>
    However it does not seem to work any ideas?

    Kind Regards

  2. #2
    HTML,CSS and JS thread not PHP related

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
  •