Jump to content

Form Help ?


GaGa
 Share

Recommended Posts

I was trying to implement this Tutorial into my contact form so i tried to change the sendmail.php file but it still gives me an error about the subject even if i entered a subject, i don`t know why ? can anyone help me plz ?this is my form

<html><div id="wrapper"><div class="message"><div id="alert"></div></div><div class="contact"><form action="sendmailexample.php" method="post" id="contactForm"><ul><li>	   <label for="cname"><span>name:<em>*</em></span><input type="text" name="name" id="cname" /></label></li><li>	   <label for="cemail"><span>email:<em>*</em></span><input type="text" name="email" id="cemail" /></label></li><li>	   <label for="csubject"><span>subject:<em>*</em></span><input type="text" name="subject" id="csubject" /></label></li><li> <label for="curl"><span>url:</span><input type="text" name="url" value="http://" id="curl" /></label></li><li class="special"><label for="last">Don't fill this in:</label><input type="text" name="last" value="" id="last" /></li><li><label for="cmessage"><span>message:<em>*</em></span> <textarea name="message" id="cmessage" cols="50" rows="12"></textarea></label></li><li class="submitbutton"><input type="submit" value="submit" id="csubmit" class="submit right"/></li></ul></form><p>Thanks to Mid Mo Design for the <a href="http://midmodesign.com/news/coding/jquery-ajax-contact-form-with-honeypot/">AJAX Contact Form</a>.</p></div></div>

and this is the sendmail file after i modified it

<?php//		Who you want to recieve the emails from the form. (Hint: generally you.)$sendto = 'youremail@example.com';//		The subject you'll see in your inbox$subject = 'Contact from contact form';//		Message for the user when he/she doesn't fill in the form correctly.$errormessage = 'Oops! There seems to have been a problem. May we suggest...';//		Message for the user when he/she fills in the form correctly.$thanks = "Thanks for the email! We'll get back to you as soon as possible!";//		Message for the bot when it fills in in at all.$honeypot = "You filled in the honeypot! If you're human, try again!";//		Various messages displayed when the fields are empty.$emptyname =  'Entering your name?';$emptyemail = 'Entering your email address?';$emptysubject = 'Entering a subject?';$emptymessage = 'Entering a message?';//	   Various messages displayed when the fields are incorrectly formatted.$alertname =  'Entering your name using only the standard alphabet?';$alertemail = 'Entering your email in this format: <i>name@example.com</i>?';$alertsubject = 'You must enter a subject';$alertmessage = "Making sure you aren't using any parenthesis or other escaping characters in the message? Most URLS are fine though!";// --------------------------- Thats it! don't mess with below unless you are really smart! ---------------------------------//Setting used variables.$alert = '';$pass = 0;// Sanitizing the data, kind of done via error messages first. Twice is better! ;-)function clean_var($variable) {	$variable = strip_tags(stripslashes(trim(rtrim($variable))));  return $variable;}//The first if for honeypot.if ( empty($_REQUEST['last']) ) {	// A bunch of if's for all the fields and the error messages.if ( empty($_REQUEST['name']) ) {	$pass = 1;	$alert .= "<li>" . $emptyname . "</li>";} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['name'] ) ) {	$pass = 1;	$alert .= "<li>" . $alertname . "</li>";}if ( empty($_REQUEST['email']) ) {	$pass = 1;	$alert .= "<li>" . $emptyemail . "</li>";} elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_REQUEST['email']) ) {	$pass = 1;	$alert .= "<li>" . $alertemail . "</li>";}if ( empty($_REQUEST['subject']) ) {	$pass = 1;	$alert .= "<li>" . $emptysubject . "</li>";} elseif ( !ereg( "[][{}()*+?.\\^$|]", $_REQUEST['subject'] ) ) {	$pass = 1;	$alert .= "<li>" . $alertsubject . "</li>";}if ( empty($_REQUEST['message']) ) {	$pass = 1;	$alert .= "<li>" . $emptymessage . "</li>";} elseif ( ereg( "[][{}()*+?\\^$|]", $_REQUEST['message'] ) ) {	$pass = 1;	$alert .= "<li>" . $alertmessage . "</li>";}	//If the user err'd, print the error messages.	if ( $pass==1 ) {		//This first line is for ajax/javascript, comment it or delete it if this isn't your cup o' tea.	echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";	echo "<b>" . $errormessage . "</b>";	echo "<ul>";	echo $alert;	echo "</ul>";	// If the user didn't err and there is in fact a message, time to email it.	} elseif (isset($_REQUEST['message'])) {				//Construct the message.		$message = "From: " . clean_var($_REQUEST['name']) . "\n";		$message .= "Email: " . clean_var($_REQUEST['email']) . "\n";		$message .= "subject: " . clean_var($_REQUEST['subject']) . "\n";		$message .= "Message: \n" . clean_var($_REQUEST['message']);		$header = 'From:'. clean_var($_REQUEST['email']);		//Mail the message - for production		//mail($sendto, $subject, $message, $header);//This is for javascript, 		echo "<script>$(\".message\").hide(\"slow\").show(\"slow\").animate({opacity: 1.0}, 4000).hide(\"slow\"); $(':input').clearForm() </script>";		echo $thanks;		die();//Echo the email message - for development		echo "<br/><br/>" . $message;	}	//If honeypot is filled, trigger the message that bot likely won't see.} else {	echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";	echo $honeypot;}?>

Link to comment
Share on other sites

I don't get any errors from the subject. If you want to test the regular expression yourself, go here:http://www.regextester.com/For the dialect choose "ereg", and turn all of the flags off. Paste this into the regex field:[][{}()*+?.\\^$|]You can type text into the text box to see if it matches. If there is a match (if your script would give an error), it will show the matching characters in red. It will match on any of the above characters I listed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...