Jump to content

feedback form


ROCKINDANO

Recommended Posts

Hi everyone, i am working on a feedback form and its not sending the email. can someone help?

 

this is what i have:

this is the form page. feedbackform.php

    <div id="middle">
	<form method="post" action="processfeedback.php">
        	<p>Your Name:<br /><input type="text" name="custname" /><br />
            Your Email: <br /><input type="text" name="email" /><br />
            Your Feedback: <br /><textarea name="feedback" cols="50" rows="10"></textarea><br />
            what department:  Solid Waste: <input type="radio" name="searchtype" checked="checked" value="solid" />
            Public Works:  <input type="radio" name="searchtype" value="public" /><br /><br /></p>
            <input name="submit" type="submit" value="submit" /><input type="reset" name="Reset" value="Clear Fields" />            
        </form>
    </div><!-- END OF MIDDLE CONTAINER -->

 

 

this is the processfeedback.php

    	<?php
		//create short variable names
		$custname = $HTTP_POST_VARS['custname'];
		$email = $HTTP_POST_VARS['email'];
		$feedback = $HTTP_POST_VARS['feedback'];

		if (!ereg('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email))
		{
			print "that is not a valid email address. Please return to the previous page and try again.";
		}
		$toaddress = '[email protected]';
		if(eregi('test', $feedback)) 
			$toaddress = '[email protected]';
		else  if(eregi('test', $feedback))
			$toaddress = '[email protected]';

		$subject = 'Feed Back from website';
		$mailcontent = 'Customer Name: '.$custname."\n"
						.'Customer email: '.$email."\n"
						."Customer's feedback: \n".$feedback."\n";
		$fromaddress = 'From: [email protected]';

		mail($toaddress, $subject, $mailcontent, $fromaddress);
	?>

Link to comment
https://forums.phpfreaks.com/topic/171189-feedback-form/
Share on other sites

one thing I spotted

 

if(eregi('test', $feedback)) 
            $toaddress = '[email protected]';
         else  if(eregi('test', $feedback))
            $toaddress = '[email protected]';

 

this block tests the same thing twice, but has two different outcomes. Perhaps its sending an email to an address you don't expect it to because of this. Also, I think eregi() is deprecated

Link to comment
https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902741
Share on other sites

well how exactly are you testing it. It seems that you just check if the feedback response has the word "test" in it, and if so it sends to a specific email address.

 

 

Oh on a completely unrelated note. the following code:

if (!ereg('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email))
         {
            print "that is not a valid email address. Please return to the previous page and try again.";
            #insert a die() or an exit() command here if you want to terminate the script
         }

 

doesn't do anything but print its not a valid email address. if you want to stop it, use an exit() or something.

 

 

back on topic, what email address should it be send to? try writing

 

if (mail($toaddress, $subject, $mailcontent, $fromaddress)){
echo "Success!";
}
else {
echo "Epic Fail";
}

 

instead of just

 mail($toaddress, $subject, $mailcontent, $fromaddress); 

 

and see what happens

Link to comment
https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902751
Share on other sites

well i am trying to test out using my own email. it has to send it to the "$toaddress = '[email protected]'; by default.

 

now if it finds the word test in the email it should send it to the [email protected].

 

but it doesn't pass where it checks if its a valid email part and dies.

Link to comment
https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-902755
Share on other sites

Replace your old processfeedback.php with:

 

<?php
//Customer Name
$custname = $_REQUEST['custname'] ;

//Customers Email
$email = $_REQUEST['email'] ;

//Customers Feedback
$message = $_REQUEST['feedback'] ;


//Subject
$subject = "Feed Back from website";


//You (to address)
$to = "[email protected]";

$headers = "From: $email";

$sent = mail($to, $subject, $message, $headers) ;

if($sent)
{print "W000t! It works!"; }
else
{print "Damn! It dont work"; }
?>

Link to comment
https://forums.phpfreaks.com/topic/171189-feedback-form/#findComment-903003
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.