Jump to content

form php POLL not sending me email


silverglade

Recommended Posts

EDIT, CORRECTION- IT WENT TO MY JUNKMAIL. HOW DO I PREVENT THAT? ALSO, IT DID NOT PUT THE USER'S IP IN THE 'POSTER' FIELD IN DB SO I CAN PREVENT MULTIPLE POSTS PER PERSON.

 

Hi, I went over the code and looks good to me, I put the "poster" field in my Members table. Everything looks good, my page loads with no errors, but the email never gets sent upon submitting the form "user poll"

 

here is the relevant code, please any help greatly appreciated! thank you.

 

 

 <?php
	if($_POST['submit'])
	{
		$currentPoster = $_SERVER['REMOTE_ADDR']; // get ip of visitor
		$query = mysql_query("SELECT * FROM members WHERE poster = '$currentPoster'"); //check DB for user ip

		if (mysql_num_rows($query) > 0)  //if ip exists, user already posted
		{ 
			$error=1; //this is t o set if error message echoes or not.
   				  $errorMessage=" You already posted to this poll"; // echo error to the multiple post prick//echoed out below
		} else {
			  $query2 = mysql_query("INSERT INTO members(poster) VALUES ('$currentPoster')");// insert new ip into DB

   				 $email_from = '.info POLL'; // email information

   				 $email_subject = " POLL RESPONDER";

  				  $email_body = "You have received a new poll message from the user ip address of  $currentPoster.\n".
                            "Here is the message:\n $userfeedback";
		////////////////////////////////////////////////////////////////////////
		//SEND THE EMAIL

  					$to = "xxxx@hotmail.com"; //email headers

				 $headers = "From: $email_from \r\n";

				 $headers .= "Reply-To: no one \r\n";

				 mail($to,$email_subject,$email_body,$headers);// sends off the final email.
			 $error=0;
			 $goodmessage="Thank you for your feedback!";

		}		


	}			 


		?>


				 <form id="userfeedback" method="post" action="index.php">
				   <p> 
				<textarea name="userfeedback" id="userfeedback" cols="45" rows="5"></textarea> 
				<input type="submit" id="submit" name="submit"/> <input type="reset" id="reset" name="reset"/>

				</p>
				</form>
				<br/>

				<?php 
					if($error=1)
					{
					echo $errorMessage;
					}else {
					echo $goodmessage;
					}
	?>

Link to comment
Share on other sites

In addition to the user's ip not updating into the database, I cant get the reCaptcha to work. It says "invalid text entered" or something similar when page loads.

 

 

Here is the code. relating to the captcha

 

 

 <?php
	if($_POST['submit'])
	{
		$currentPoster = $_SERVER['REMOTE_ADDR']; // get ip of visitor
		$query = mysql_query("SELECT * FROM members WHERE poster = '$currentPoster'"); //check DB for user ip

		if (mysql_num_rows($query) > 0)  //if ip exists, user already posted
		{ 
			$error=1; //this is t o set if error message echoes or not.
   				  $errorMessage=" You already posted to this poll"; // echo error to the multiple post prick//echoed out below
		} else {
			  $query2 = mysql_query("INSERT INTO members(poster) VALUES ('$currentPoster')");// insert new ip into DB

   				 $email_from = ' info POLL'; // email information

   				 $email_subject = " OLL RESPONDER";

  				  $email_body = "You have received a new poll message from the user ip address of  $currentPoster.\n".
                            "Here is the message:\n $userfeedback";
		////////////////////////////////////////////////////////////////////////
		//SEND THE EMAIL

  					$to = " 1@hotmail.com"; //email headers

				 $headers = "From: $email_from \r\n";

				 $headers .= "Reply-To: no one \r\n";

				 mail($to,$email_subject,$email_body,$headers);// sends off the final email.
			 $error=0;
			 $goodmessage="Thank you for your feedback!";

		}		


	}			 


		?>


				 <form id="userfeedback" method="post" action="index.php">
				   <p> 
				<textarea name="userfeedback" id="userfeedback" cols="45" rows="5"></textarea> 
                    	<?php require_once('recaptchalib.php');
					$publickey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // RECAPTCHA
					echo recaptcha_get_html($publickey);?>

				<input type="submit" id="submit" name="submit"/> <input type="reset" id="reset" name="reset"/>

				</p>
				</form>
				<br/>

				<?php 
					if($error=1)
					{
					echo $errorMessage;
					}else {
					echo $goodmessage;
					}





						require_once('recaptchalib.php');
						$privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
						$resp = recaptcha_check_answer ($privatekey,
						$_SERVER["REMOTE_ADDR"],
						$_POST["recaptcha_challenge_field"],
						$_POST["recaptcha_response_field"]);
						if (!$resp->is_valid) {
						die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
						"(reCAPTCHA said: " . $resp->error . ")");
						}
						?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.