The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Contact form error
pnwdude
post 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() );

}
?>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 27 2017, 05:03 PM
Post #2


.
********

Group: WDG Moderators
Posts: 7,728
Joined: 10-August 06
Member No.: 7



Please post the HTML form that goes with the above script.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pnwdude
post Jan 27 2017, 05:15 PM
Post #3





Group: Members
Posts: 3
Joined: 27-January 17
Member No.: 26,283



QUOTE(Christian J @ Jan 27 2017, 02:03 PM) *

Please post the HTML form that goes with the above script.
Is this the section you need? Sorry, still learning...

<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>

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pnwdude
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 27 2017, 09:23 PM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,766
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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th November 2017 - 03:37 AM