Contact form error |
Contact form error |
pnwdude |
Jan 27 2017, 04:09 PM
Post
#1
|
Group: Members Posts: 3 Joined: 27-January 17 Member No.: 26,283 |
Hi everyone. I’m trying to figure out what’s wrong with the coding of my contact form. My website is based off a template which came with positive reviews and no mention of errors with sending messages from the form. When I attempt to send a message it just results in a continuous loading symbol. Here’s the code (with my email address replaced with something generic). Thank you.
<?php /************************ * Variables you can change *************************/ $mailto = “example@email.com"; // Enter your mail addres here. $name = ucwords($_POST['name']); $subject = "Message from $name"; // Enter the subject here. $email = $_POST['email']; $message = $_POST['message']; if(strlen($_POST['name']) < 1 ){ echo 'email_error'; } else if(strlen($email) < 1 ) { echo 'email_error'; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) { echo 'email_error'; } else if(strlen($message) < 1 ){ echo 'email_error'; } else { // NOW SEND THE ENQUIRY $email_message="\n\n" . "Name: " . ucwords($name) . "\n" . "Email: " . $email . "\n" . "Comments: " . "\n" . $message . "\n" . "\n\n" ; $email_message = trim(stripslashes($email_message)); mail($mailto, $subject, $email_message, "From: \"$vname\" <".$email.">\nReply-To: \"".ucwords($name)."\" <".$email.">\nX-Mailer: PHP/" . phpversion() ); } ?> |
Christian J |
Jan 27 2017, 05:03 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,658 Joined: 10-August 06 Member No.: 7 |
Please post the HTML form that goes with the above script.
|
pnwdude |
Jan 27 2017, 05:15 PM
Post
#3
|
Group: Members Posts: 3 Joined: 27-January 17 Member No.: 26,283 |
Please post the HTML form that goes with the above script. <div id="contactFormArea"> <!-- Contact Form Start //--> <form action="#" id="contactform"> <fieldset> <label>Name</label> <input type="text" name="name" class="textfield" id="name" value="" /> <div class="clear"></div> <label>E-mail</label> <input type="text" name="email" class="textfield" id="email" value="" /> <div class="clear"></div> <label>Subject</label> <input type="text" name="subject" class="textfield" id="subject" value="" /> <div class="clear"></div> <label>Message</label> <textarea name="message" id="message" class="textarea" cols="2" rows="4"></textarea> <div class="clear"></div> <label> </label> <input type="submit" name="submit" class="buttoncontact" id="buttonsend" value="Submit" /> <span class="loading" style="display: none;">Please wait..</span> <div class="clear"></div> </fieldset> </form> |
pnwdude |
Jan 27 2017, 07:18 PM
Post
#4
|
Group: Members Posts: 3 Joined: 27-January 17 Member No.: 26,283 |
Appears to be working now. I guess the page needed to be loaded from my server rather than my pc.
|
pandy |
Jan 27 2017, 09:23 PM
Post
#5
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 Joined: 9-August 06 Member No.: 6 |
I should work locally provided the script is on a server and that you have the URL to it instead of the hash sign here.
CODE <form action="#" id="contactform"> On the other hand this curly quote should stop if from working. CODE “example@email.com"; But maybe that happened when you edited the email out for the forum. Don't use Word and the like. |
Lo-Fi Version | Time is now: 26th April 2024 - 02:28 PM |