Contact Form Incomplete? Driving me absolutely nuts. Help!

  • carringtonadkins
  • Born
  • Born
  • carringtonadkins
  • Posts: 2

Post 3+ Months Ago

Good afternoon.

New to Ozzu. Just bought a template and contact not working. If I weren't a 2 on a low-high scale of 1-10, I might figure it out. But...I"m not.

So, just wanna see if you smarties can help with my Contact Form. PLEASE!


1) HTML:

HTML Code: [ Select ]
<div class="medium-7 columns">
      <form>
          <fieldset>
               <input type="text" placeholder="Your Name" />
               <input type="text" placeholder="Your Email" />
         </fieldset>
         <textarea rows="10" placeholder="Your Comment"></textarea>
              <input type="submit" class="button button-small" value="Send Message" />
     </form>
</div>
  1. <div class="medium-7 columns">
  2.       <form>
  3.           <fieldset>
  4.                <input type="text" placeholder="Your Name" />
  5.                <input type="text" placeholder="Your Email" />
  6.          </fieldset>
  7.          <textarea rows="10" placeholder="Your Comment"></textarea>
  8.               <input type="submit" class="button button-small" value="Send Message" />
  9.      </form>
  10. </div>



That's how it came. No other ties to script.js nor any .php file included. :( So, I researched best I could and added this to script.js:

2) // Contact Form Code

JAVASCRIPT Code: [ Select ]
$('#form-button').click(function () {
 
        var name = $('#form-name').val();
        var email = $('#form-email').val();
        var message = $('#form-msg').val();
        var error = 0;
 
        if (name === '' || email === '' || message === '') {
            error = 1;
            $('#details-error').fadeIn(200);
        } else {
            $('#details-error').fadeOut(200);
        }
 
        if (!(/(.+)@(.+){2,}\.(.+){2,}/.test(email))) {
            $('#details-error').fadeIn(200);
            error = 1;
        }
 
        var dataString = 'name=' + name + '&email=' + email + '&text=' + message;
 
        if (error === 0) {
            $.ajax({
                type: "POST",
                url: "mail.php",
                data: dataString,
                success: function () {
                    $('#details-error').fadeOut(1000);
                    $('#form-sent').fadeIn(1000);
                }
            });
            return false;
        }
 
    });
  1. $('#form-button').click(function () {
  2.  
  3.         var name = $('#form-name').val();
  4.         var email = $('#form-email').val();
  5.         var message = $('#form-msg').val();
  6.         var error = 0;
  7.  
  8.         if (name === '' || email === '' || message === '') {
  9.             error = 1;
  10.             $('#details-error').fadeIn(200);
  11.         } else {
  12.             $('#details-error').fadeOut(200);
  13.         }
  14.  
  15.         if (!(/(.+)@(.+){2,}\.(.+){2,}/.test(email))) {
  16.             $('#details-error').fadeIn(200);
  17.             error = 1;
  18.         }
  19.  
  20.         var dataString = 'name=' + name + '&email=' + email + '&text=' + message;
  21.  
  22.         if (error === 0) {
  23.             $.ajax({
  24.                 type: "POST",
  25.                 url: "mail.php",
  26.                 data: dataString,
  27.                 success: function () {
  28.                     $('#details-error').fadeOut(1000);
  29.                     $('#form-sent').fadeIn(1000);
  30.                 }
  31.             });
  32.             return false;
  33.         }
  34.  
  35.     });


Plus, I created a main.php file in main directory that includes this:

3)

PHP Code: [ Select ]
<?php
if($_POST){
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['text'];
 
 
$to = "[EMAIL_ADDRESS_GOES_HERE";
$subject = "Contact Form Submission";
$message = $message;
$header = "From: $name <" . $email . ">";
 
 
// And then to send it
 
 
mail($to, $subject, $message, $header);
}
?>
  1. <?php
  2. if($_POST){
  3.     $name = $_POST['name'];
  4.     $email = $_POST['email'];
  5.     $message = $_POST['text'];
  6.  
  7.  
  8. $to = "[EMAIL_ADDRESS_GOES_HERE";
  9. $subject = "Contact Form Submission";
  10. $message = $message;
  11. $header = "From: $name <" . $email . ">";
  12.  
  13.  
  14. // And then to send it
  15.  
  16.  
  17. mail($to, $subject, $message, $header);
  18. }
  19. ?>


Result? I get nothing. No email in my inbox, no '?" at end of URL....nothing. HELP!!

Any very basic way to post what I need that's copy/pastable would be a blessing. I don't know what else to do (no word after several attempts to reach template creator.)

Thanks!
Moderator Remark: Put proper bbcode tags around code blocks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Did you happen to buy a template through our website? or somewhere else? The reason I ask if it was here I might be able to provide you specific instructions for the template.

As far as to what you posted there, from what I can tell nothing is really tied together at all. You could have that form submit without using Javascript at all by adding a action attribute to the form element and putting the script that it is supposed to process the form data through. If you want to use AJAX like you are, then you need to update your HTML so that the button element has an id of "form-button" since that is JavaScript event it is waiting to be clicked upon.

I am sure there are more issues, but it might be easier for you to find a pre-made contact script and then follow the instructions for how to use it. While your PHP portion of the script may work, from what I see there you have no sanitation at all which means it will most likely eventually be abused by spammers once they figure out that they can basically hack its input.

Hope that helps some.
  • carringtonadkins
  • Born
  • Born
  • carringtonadkins
  • Posts: 2

Post 3+ Months Ago

Thanks for responding. Yes, that did help some.

I bought the template on Themeforest. Figured template would come ready for me to just input my email address and wa-lah. Guess not. Didn't know Ozzu had templates for sale.

I guess I'll have to learn how to "have that form submit without using Javascript at all by adding an action attribute to the form element." Gotta do something. Only paid $13 but I must make it work.

Re: "sanitation"...guess I have so much to learn. I need to get my hands on a copy/pastable 'clean' contact form.

Thanks, again, for input. Search continues.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 67 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.