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 = 'dvera@ci.edinburg.tx.us';
		if(eregi('test', $feedback)) 
			$toaddress = 'd_veraz@hotmail.com';
		else  if(eregi('test', $feedback))
			$toaddress = 'rockindano@hotmail.com';

		$subject = 'Feed Back from website';
		$mailcontent = 'Customer Name: '.$custname."\n"
						.'Customer email: '.$email."\n"
						."Customer's feedback: \n".$feedback."\n";
		$fromaddress = 'From: dvera@ci.edinburg.tx.us';

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

Link to comment
Share on other sites

one thing I spotted

 

if(eregi('test', $feedback)) 
            $toaddress = 'd_veraz@hotmail.com';
         else  if(eregi('test', $feedback))
            $toaddress = 'rockindano@hotmail.com';

 

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
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
Share on other sites

well i am trying to test out using my own email. it has to send it to the "$toaddress = 'dvera@ci.edinburg.tx.us'; by default.

 

now if it finds the word test in the email it should send it to the d_veraz@hotmail.com.

 

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

Link to comment
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 = "dvera@ci.edinburg.tx.us";

$headers = "From: $email";

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

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

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.