Jump to content

Help with Feedback form


bengaluru

Recommended Posts

Can somebody help me with this php.

This is the simplest php form getting feedback from my visitors.  I have the same form on my other site and it is working fine.  But nowworking with my new site.

My form is fine.  I am having trouble with the response.  The problem is that whenever a user completes the form, instead of the "thank you",  the No response page is displayed and no email is received by me.  the page that is displayed (No response) says that the user has not completed all the fields and hence the response is not sent.

---------------------------------------------------------------  This is my php

<?if (($name == "") && ($email == "") && ($comments == "")) {
header("Location: http://www.mysite.com/noresponse.htm");
exit;}


$msg = "E-MAIL SENT FROM $email\n";
$msg .= "Sender's Name: $name\n";
$msg .= "Sender's E-Mail: $email\n";
$msg .= "Sender's Place: $place\n";
$msg .= "Message: $comments\n\n";


$to = "[email protected]";
$subject = " Feedback";
$mailheaders = "From: Response Forms <> \n";
$mailheaders .= "Reply-To: $email\n\n";

mail($to, $subject, $msg, $mailheaders);
?>
<HTML>
<HEAD><TITLE>My site - Thank You</TITLE>
<meta http-equiv="refresh" content="10;url=http://www.mysite.com/contactus.htm">
</HEAD>
<BODY>
<p><img src="images/banner.jpg" width="446" height="100"><img src="images/shubha.jpg" width="354" height="100"></p>
    <hr>

<H1>Thank you. Your response is valuable to us.</H1>

<P><strong>Your Name:</strong>
<? echo "$name"; ?>
<P><strong>Your E-Mail Address:</strong>
<? echo "$email"; ?>
<P><strong>You are from:</strong>
<? echo "$place"; ?>
<P><strong>Message:</strong>
  <? echo "$comments"; ?>
<H3>Please wait and you will be taken back to the page you were viewing</H3>

</BODY>
</HTML>
-------------------------------------------------------------------------------------------

Any help ?
Link to comment
https://forums.phpfreaks.com/topic/31300-help-with-feedback-form/
Share on other sites

[code]
<?php
if (!isset($name) || !isset($email) || !isset($comments)) {
header("Location: http://www.mysite.com/noresponse.htm");
exit;
}else {


$msg = "E-MAIL SENT FROM $email\n";
$msg .= "Sender's Name: $name\n";
$msg .= "Sender's E-Mail: $email\n";
$msg .= "Sender's Place: $place\n";
$msg .= "Message: $comments\n\n";


$to = "[email protected]";
$subject = " Feedback";
$mailheaders = "From: Response Forms <> \n";
$mailheaders .= "Reply-To: $email\n\n";

$send = mail($to, $subject, $msg, $mailheaders);
if($send){
?>
<HTML>
<HEAD><TITLE>My site - Thank You</TITLE>
<meta http-equiv="refresh" content="10;url=http://www.mysite.com/contactus.htm">
</HEAD>
<BODY>
<p><img src="images/banner.jpg" width="446" height="100"><img src="images/shubha.jpg" width="354" height="100"></p>
 
<H1>Thank you. Your response is valuable to us.</H1>

<P><strong>Your Name:</strong>
<? echo "$name"; ?>
<P><strong>Your E-Mail Address:</strong>
<? echo "$email"; ?>
<P><strong>You are from:</strong>
<? echo "$place"; ?>
<P><strong>Message:</strong>
<? echo "$comments"; ?>
<H3>Please wait and you will be taken back to the page you were viewing</H3>

</BODY>
</HTML>
<?php
}else {
echo "your mail was not delivered";
}
}
?>
[/code]
No my php is giving errors with your code.  Can U post the exact code that I should be using like you did before.  Thanks so much for your help.

But what I dont understand is the same php works fine in my other site and why does it not work now ?
What am I doing wrong ?
[code=php:0]
<?php
$name = $_POST[name];
$email = $_POST[email];
$comments = $_POST[comments];
if (!isset($name) || !isset($email) || !isset($comments)) {
header("Location: http://www.mysite.com/noresponse.htm");
exit;
}else {


$msg = "E-MAIL SENT FROM $email\n";
$msg .= "Sender's Name: $name\n";
$msg .= "Sender's E-Mail: $email\n";
$msg .= "Sender's Place: $place\n";
$msg .= "Message: $comments\n\n";


$to = "[email protected]";
$subject = " Feedback";
$mailheaders = "From: Response Forms <> \n";
$mailheaders .= "Reply-To: $email\n\n";

$send = mail($to, $subject, $msg, $mailheaders);
?>
<HTML>
<HEAD><TITLE>My site - Thank You</TITLE>
<meta http-equiv="refresh" content="10;url=http://www.mysite.com/contactus.htm">
</HEAD>
<BODY>
<p><img src="images/banner.jpg" width="446" height="100"><img src="images/shubha.jpg" width="354" height="100"></p>
 
<H1>Thank you. Your response is valuable to us.</H1>

<P><strong>Your Name:</strong>
<? echo "$name"; ?>
<P><strong>Your E-Mail Address:</strong>
<? echo "$email"; ?>
<P><strong>You are from:</strong>
<? echo "$place"; ?>
<P><strong>Message:</strong>
<? echo "$comments"; ?>
<H3>Please wait and you will be taken back to the page you were viewing</H3>

</BODY>
</HTML>
<?php
}
?>
[/code]
Thanks my friend.  It worked.

One more question : what if I have to get the response at 2 email id's.

right now it says [email protected]

I tried this - $to = "[email protected]";"[email protected]";

But it does not work. 

2. for some reason the Place of the sender is not diaplayed both at the thank You page and the email that I receive.  You know why ?

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.