Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 06-09-2013, 03:34 PM
mrcountry mrcountry is offline
Contributing Member
 
Join Date: 03-02-08
Posts: 88
iTrader: 0 / 0%
Please help with form

I am trying to put a simple contact form on my site and I just cant figure it out. Please tell me what I can do in order to get this form to work. Below is both the html and javascript, I also see referrence to a process.php file but I dont have the code for it.

Here is the code that is on the html page where the form is located

HTML Code:
<div id="contact_form"> <form id="contact" action=""> <fieldset> <label for="name" id="name_label">Name</label> <input type="text" name="name" id="name" size="30" value="" class="text-input" /> <span class="error" id="name_error">Please enter name !</span> <label for="email" id="email_label">Email</label> <input type="text" name="email" id="email" size="30" value="" class="text-input" /> <span class="error" id="email_error">Please enter email address !</span> <span class="error" id="email_error2">Please enter valid email address !</span> <label for="msg" id="msg_label">Your Message</label> <textarea cols="25" rows="5" name="msg" id="msg" class="text-input"></textarea> <span class="error" id="msg_error">Please enter message !</span> <input type="submit" name="submit" class="button" id="submit_btn" value="Send Message"/> </fieldset> </form> <br /> </div>


Below is the JS code
PHP Code:
  $(function() {
  $(
'.error').hide();
  $(
".button").click(function() {
        
// validate and process form
        // first hide any error messages
    
$('.error').hide();
        
      var 
name = $("input#name").val();
        if (
name == "") {
      $(
"span#name_error").show();
      $(
"input#name").focus();
      return 
false;
    }
      var 
email = $("input#email").val();
      if (
email == "") {
      $(
"span#email_error").show();
      $(
"input#email").focus();
      return 
false;
    }
    
    var 
emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if(!
emailReg.test(email)) {
    $(
"span#email_error2").show();
    $(
"input#email").focus();
      return 
false;
    }
    
      var 
msg = $("textarea#msg").val();
      if (
msg == "") {
      $(
"span#msg_error").show();
      $(
"textarea#msg").focus();
      return 
false;
    }
        
        var 
dataString 'name='name '&email=' email '&msg=' msg;
        
//alert (dataString);return false;
        
      
$.ajax({
      
type"POST",
      
url"process.php",
      
datadataString,
      
success: function() {
        $(
'#contact_form').html("<div id='message'></div>");
        $(
'#message').html("Contact Form Submitted!. We will be in touch soon.")
        .
hide()
        .
fadeIn(1500, function() {
          $(
'#message');
        });
      }
     });
    return 
false;
    });
}); 
Please Help!!!

Last edited by HTMLBasicTutor; 06-09-2013 at 08:12 PM. Reason: add code tags
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 06-09-2013, 08:14 PM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,710
iTrader: 5 / 100%
Go back to where ever you got this or learned this from and get the process.php file. You need it complete the submit process.
 
Reply With Quote
  #3  
Old 06-10-2013, 04:01 AM
mrcountry mrcountry is offline
Contributing Member
 
Join Date: 03-02-08
Posts: 88
iTrader: 0 / 0%
I would do that if I only remembered where I got it. Thanks for nothing.
 
Reply With Quote
  #4  
Old 06-10-2013, 04:24 AM
GMF's Avatar
GMF GMF is offline
Contributing Member
 
Join Date: 11-03-11
Location: Austria
Posts: 1,213
iTrader: 0 / 0%
Found something via Google search, could be what you need, could also be irrelevant

Code:
http://forum.codecall.net/topic/55691-missing-php-file-to-process-form/
 
Reply With Quote
  #5  
Old 06-10-2013, 04:34 AM
mrcountry mrcountry is offline
Contributing Member
 
Join Date: 03-02-08
Posts: 88
iTrader: 0 / 0%
thanks I will give it a shot. Let me ask you this as well, when setting this up does it also need some sort of database set up. I am very new to the form and it's kicking my but. I wanted something simple and this has not been simple. Thanks much for the reply.
 
Reply With Quote
  #6  
Old 06-10-2013, 05:13 AM
mrcountry mrcountry is offline
Contributing Member
 
Join Date: 03-02-08
Posts: 88
iTrader: 0 / 0%
that didn't work either, thanks for trying. If you know of anywhere that I can go to learn how to set up simple contact forms I would greatly appreciate the info. Thanks and have a great day.
 
Reply With Quote
  #7  
Old 06-10-2013, 05:13 AM
GMF's Avatar
GMF GMF is offline
Contributing Member
 
Join Date: 11-03-11
Location: Austria
Posts: 1,213
iTrader: 0 / 0%
A database is not needed for sending an email via php.


What I would suggest - don't copy-paste the code. Instead, follow a tutorial and write one yourself.

There are many email php tutorials, that walk you through the process. Here is one that looks pretty good

Code:
http://webdevrefinery.com/forums/topic/1155-tutorial-how-to-send-emails-using-php/
 
Reply With Quote
  #8  
Old 06-12-2013, 09:14 AM
tomcool32 tomcool32 is offline
Contributing Member
 
Join Date: 04-08-10
Location: Mumbai
Posts: 94
iTrader: 0 / 0%
Please do a complete tutorial on forms.
Copy-pasting the code won't help.
For example, in your code you haven't even specified the form action.
You can't expect it to work if you don't specify what you want the browser to do with the inputs.

Like GMF suggested do a course/tutorial. Also what platform are you working with? Is it just HTML/CSS or is it a CMS like WordPress or Joomla or whatever. That will decide which tutorial you should learn from. Best of Luck.

P.S. HTMLBasicTutor is a very senior member you might want to be a little more polite when to speak to members rather thank saying "thanks for nothing". That's just plain rude.
 
Reply With Quote
  #9  
Old 06-14-2013, 05:09 AM
mrcountry mrcountry is offline
Contributing Member
 
Join Date: 03-02-08
Posts: 88
iTrader: 0 / 0%
thanks and I greatly appreciate the help
 
Reply With Quote
  #10  
Old 06-20-2013, 01:34 AM
BlackHatNinja's Avatar
BlackHatNinja BlackHatNinja is offline
Member
 
Join Date: 06-18-13
Posts: 40
iTrader: 0 / 0%
Get a free account at Wufoo.com .

You can make your form in seconds and embed right on your site.

This is the quick and easy fix.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mini Form, then form, then paypal? How? MissTa Coding Forum 2 03-19-2012 08:12 PM
Contact form please help to create a contact form jennypretty Coding Forum 2 07-03-2008 07:49 AM
Can't show non-modal form when modal form is displayed sypond Coding Forum 3 03-23-2007 08:31 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 09:13 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC