Web Analytics Made Easy -
StatCounter contact form - CodingForum

Announcement

Collapse
No announcement yet.

contact form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • contact form

    I have a contact form and I added my email address in it. I know the email works because it was tested. But it will not work on the website. There is some spots that say I have to add information. But I'm not sure what I'm to add. Here is the code.

    Code:
    /* ------------------------------------------------------------------
       STUFF YOU NEED TO CHANGE FOR YOUR SPECIFIC FORM
    --------------------------------------------------------------------*/
    
    // Specify the form field names your form will accept
    $whitelist = array( 'name', 'email', 'message');
    
    // Set the email address submissions will be sent to
    $email_address = '[email protected]';
    
    // Set the subject line for email messages
    $subject = 'New Contact Form Submission';
    
    /* ------------------------------------------------------------------
       END STUFF YOU NEED TO CHANGE FOR YOUR SPECIFIC FORM
    --------------------------------------------------------------------*/
    Last edited by Charisma; Sep 30, 2016, 11:17 AM.

  • #2
    I'm thinking I should of added the complete code. Just in case.

    Code:
    <?php
    function _e( $string ) {
    	return htmlentities( $string, ENT_QUOTES, 'UTF-8', false );
    }
    
    /* ------------------------------------------------------------------
       STUFF YOU NEED TO CHANGE FOR YOUR SPECIFIC FORM
    --------------------------------------------------------------------*/
    
    // Specify the form field names your form will accept
    $whitelist = array( 'name', 'email', 'message');
    
    // Set the email address submissions will be sent to
    $email_address = '[email protected]';
    
    // Set the subject line for email messages
    $subject = 'New Contact Form Submission';
    
    /* ------------------------------------------------------------------
       END STUFF YOU NEED TO CHANGE FOR YOUR SPECIFIC FORM
    --------------------------------------------------------------------*/
    
    // Instantiate variables we'll use
    $errors = array();
    $fields = array();
    $sent = null;
    
    // Check for form submission
    if ( ! empty( $_POST ) ) {
    
    	// Validate math
    	if ( intval( $_POST['human'] ) !== 7 ) {
    		$errors[] = 'Your math is suspect.';
    	}
    
    	// Validate email address
    	if ( ! empty( $_POST['email'] ) && ! filter_var( $_POST['email'], FILTER_VALIDATE_EMAIL ) ) {
    		$errors[] = 'That is not a valid email address';
    	}
    
    	// Perform field whitelisting
    	foreach ( $whitelist as $key ) {
    		$fields[$key] = $_POST[$key];
    	}
    
    	// Validate field data
    	foreach ( $fields as $field => $data ) {
    		if ( empty( $data ) ) {
    			$errors[] = 'Please enter your ' . $field;
    		}
    	}
    
    	// Check and process
    	if ( empty( $errors ) ) {
    		$sent = mail( $email_address, $subject, $fields['message'] );
    	}
    }
    
    $pageTitle = "Contact Us";
    include('inc/header.php');
    ?>
    <section class="section" id="contact-form">
      <div class="container bgWhite">
        <div class="row">
        <div  style="padding-top: 15px;">
                    <div id="myCarousel" class="carousel slide" data-ride="carousel">
                        <!-- Indicators -->
                        <ol class="carousel-indicators">
                            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                            <li data-target="#myCarousel" data-slide-to="1"></li>
                            <li data-target="#myCarousel" data-slide-to="2"></li>
                        </ol>
    
                        <!-- Wrapper for slides -->
                         <div class="carousel-inner" role="listbox">
                            <div class="item active">
                                <img src="img/AdobeStock_83234383.jpeg" alt="" width="1920" height="546">
                            </div>
                            <div class="item">
                              <img src="img/AdobeStock_110313737.jpg" alt="" width="1920" height="546">
                            </div>
                            <div class="item">
                             <img src="img/AdobeStock_72595945.jpeg" alt="" width="1920" height="546">
                            </div>
                        </div>
    
                        <!-- Left and right controls -->
                        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
            <p></p>
            <div class="container bgWhite">
        
          <div class="col-md-12">
           <h2><u>Contact Us</u></h2>
            <h3>Enter your message below</h3>
            <?php if ( ! empty( $errors ) ) : ?>
            <div class="errors">
    <p class="bg-danger"><?php echo implode( '</p><p class="bg-danger">', $errors ); ?></p>
            </div>
            <?php elseif ( $sent ) : ?>
            <div class="success">
              <p class="bg-success">Your message was sent. We'll be in touch.</p>
            </div>
            <?php endif; ?>
            <form role="form" method="post" action="Contact.php">
              <div class="form-group">
                <label for="name" class="control-label">Name</label>
                <input type="text" class="form-control" id="name" name="name" placeholder="e.g. John Doe"
                     value="<?php echo isset( $fields['name'] ) ? _e( $fields['name'] ) : '' ?>">
              </div>
              <div class="form-group">
                <label for="email" class="control-label">Email</label>
                <input type="email" class="form-control" id="email" name="email" placeholder="e.g. [email protected]"
                    value="<?php echo isset( $fields['email'] ) ? _e( $fields['email'] ) : '' ?>">
              </div>
              <div class="form-group">
                <label for="message" class="control-label">Message</label>
                <textarea class="form-control" rows="4" name="message"><?php echo isset( $fields['message'] ) ? _e( $fields['message'] ) : '' ?></textarea>
              </div>
              <div class="form-group">
                <label for="human" class="control-label">5 + 2 = ?</label>
                <input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
              </div>
              <div class="form-group">
                <input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
              </div>
            </form>
          </div>
        </div>
      </div>
    </section>
    <?php include('inc/footer.php'); ?>

    Comment


    • #3
      What is the error you are getting from the form? If any? Are you just not receiving the emails, are you getting the success or danger popup on submit?

      Let me know and I can help you further
      Riley
      Riley-Shannon.com - My Portfolio
      FraktalServices.com - My Company

      Comment


      • #4
        I see the problem, change the action attribute to "contact.php", not "Contact.php"

        Casing will ruin an entire project.

        Good luck
        Riley
        Riley-Shannon.com - My Portfolio
        FraktalServices.com - My Company

        Comment

        Working...
        X