Help with jquery |
Help with jquery |
Jan 11 2010, 08:54 PM
Post
#1
|
|
![]() Marynmissouri ![]() ![]() ![]() Group: Member Posts: 41 Joined: Jan 2008 Member No: 606,116 |
I have a website I'm uploading and it has a contact form and a jquery file but I cant seem to get the contact form to work? Should I upload it into a different folder then the website folder. Here is the contact form link.
|
|
|
|
![]() |
Jan 11 2010, 10:56 PM
Post
#2
|
|
![]() Mel Blanc was allergic to carrots. ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Designer Posts: 6,371 Joined: Aug 2008 Member No: 676,291 |
Huh? What exactly are you trying to use jQuery in the contact form? You don't really need jQuery for a contact form; you need PHP and if you were thinking of using it for real time errors, you need to use AJAX.
Also, I don't even see a script tag in your head tags that even calls jQuery. CODE <script type="text/javascript" src="path/to/jquery.js"></script> path/to/ would be the path (directories, respectively) to where the jQuery file is located. And to get the form working, you need form tags. The input tags and input button won't work unless you have an action to call on to submit. You also have to add name properties to your input fields so a .PHP file can read it and submit it and for properties to your label tags (for valid XHTML, or whatnot). So, this: CODE <div class="contact_form"> <div class="form_row"> <label class="contact">name:</label> <input type="text" class="contact_input" /> </div> <div class="form_row"> <label class="contact">email:</label> <input type="text" class="contact_input" /> </div> <div class="form_row"> <label class="contact">phone:</label> <input type="text" class="contact_input" /> </div> <div class="form_row"> <label class="contact">message:</label> <textarea class="contact_textarea" rows="" cols="" ></textarea> </div> <div class="form_row"> <input type="image" src="images/send.gif" class="send"/> </div> </div> should be: CODE <div class="contact_form"> <form method="POST" action="contact.php" enctype="multipart/form-data"> <div class="form_row"> <label class="contact" for="name">name:</label> <input type="text" class="contact_input" name="name" /> </div> <div class="form_row"> <label class="contact" for="email">email:</label> <input type="text" class="contact_input" name="email" /> </div> <div class="form_row"> <label class="contact" for="phone">phone:</label> <input type="text" class="contact_input" name="phone" /> </div> <div class="form_row"> <label class="contact" for="message">message:</label> <textarea class="contact_textarea" rows="" cols="" name="message" ></textarea> </div> <div class="form_row"> <input type="image" src="images/send.gif" class="send"/> </div> </form> </div> Ok, so let me run this down a bit.
CODE <?php // Define variables according to parameters $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message'] // Define a variable to count how many fields were submitted (posted) $count = count($_POST); // Now, if the count of the field submitted is greater than zero (or, not empty), submit the form if ($count > 0) { // Let's check for some errors. All of this simply checks if all fields are empty or if at least one of them are empty, and if so, redirect to an error page (which you should make). if ((!$name && !$email && !$phone && !$message) || (!$name || !$email || !$phone || !$message)) { header ('Location: http://www.hannibalinfo.com/error.html'); } // Now, if there aren't any errors with null or empty fields, check also if the email address is valid. else if (!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) { header ('Location: http://www.hannibalinfo.com/error.html'); } // Otherwise, submit the data and mail it to an email address. else { // Define the neccessary variables needed to email a message. $to = 'contact@hannibalinfo.com'; $subject = 'New Message'; $message = "A new message has arrived. Refer below to read it.\n\n\"$message\"\n\n"; $from = "From: $name $email\r\n"; // Now, use the mail function to send the message contents and information. mail ($to, $subject, $message, $from); // Once finished, redirect to a success page (which you should make as well). header ('Location: http://www.hannibalinfo.com/success.html'); } } // Just in case error checking for empty fields didn't work, redirect to error page. else { header ('Location: http://www.hanibbalinfo.com/error.html'); } ?> As far as jQuery goes, I'm not sure what you really need for that. I mean, you could use AJAX to check for errors in real time (without going to another page or refreshing the page) and probably use jQuery on the side as well to animate the errors. Otherwise, there's not really a need for it. |
|
|
|
marynmissouri Help with jquery Jan 11 2010, 08:54 PM
marynmissouri Thanks for the info. I'm going to work on it t... Jan 12 2010, 09:30 AM
fixtatik Hrm, well...a bit on Mike's post.
- You don... Jan 12 2010, 10:13 AM
Mikeplyts QUOTE(fixtatik @ Jan 12 2010, 12:13 PM) A... Jan 12 2010, 05:32 PM
fixtatik Son, your face must be stinging red by now. :P Jan 12 2010, 06:00 PM
marynmissouri I'm so confused right now? I do have a jquery ... Jan 12 2010, 06:50 PM
Mikeplyts You don't just upload the files, though. You h... Jan 13 2010, 12:43 AM
marynmissouri I'm new at this so please be patient with me..... Jan 15 2010, 11:21 PM
Mikeplyts Oh, be sure that contact.php is only PHP code, no ... Jan 15 2010, 11:37 PM
marynmissouri Thanks Mike, I appreciate all of the help. I will ... Jan 15 2010, 11:46 PM
Mikeplyts Yep, no problem. Jan 15 2010, 11:52 PM
manny-the-dino Topic Closed, and Moved to Resolved Topics. Please... Apr 2 2010, 01:00 PM![]() ![]() |