Help with feedback form
Moderator: General Moderators
Help with feedback form
I'm getting an odd, incomplete message at the end of my feedback form. I'm wondering if someone can identify the cause. It follows hitting the "submit" button at the end of this form:
http://www.sisterbecky.com/acf/tour.htm
The php page is at:
http://www.sisterbecky.com/acf/tour-feedback.php
Thanks for any help.
http://www.sisterbecky.com/acf/tour.htm
The php page is at:
http://www.sisterbecky.com/acf/tour-feedback.php
Thanks for any help.
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
Since you're using a client side to bring a pop up, I assume javascript, and it does not relay the message, one of two errors is most likely the cause. Either your message that is meant to be sent is not actually in the right place or in the place period, or you may have made an error in writing the javascript.
What you should do is bring the code up, so we can see it, the php is really the one you need to place here, but thejavascript would make helping you a bit easier.
What you should do is bring the code up, so we can see it, the php is really the one you need to place here, but thejavascript would make helping you a bit easier.
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
This is what I see when I look at source
it should be something like this
Code: Select all
<script language="JavaScript" type="text/JavaScript">
alert();
</script>
Your message was sent. Thank you for contacting us,
we will be in touch shortly.Code: Select all
<script language="Javascript">
//this bit blocks the code from being processed for old browsers
<!--
//
//as far as this alert is concerned, you need to actually have something in there..
alert ("This is a Javascript Alert")
//-->
</script>feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Here's the code. This is a form I borrowed, I do understand the php fairly well, but I haven't any idea what the javascript is supposed to be doing, so it is quite likely there's an error there.Code: Select all
<?
echo '<script language="JavaScript" type="text/JavaScript">
alert('.$_POST[$varsd].');
</script>
';
$send_to = "linda@lkcwebdesign.com";
$recipient = "linda@lkcwebdesign.com";
$subject = "Aarons Creek Farm Tour Feedback";
$additional_headers = "From: linda@lkcwebdesign.com\r\n";
$additional_headers .="Content-type: text/html; charset=iso-8859-1\r\n";
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$fax = $_POST['fax'] ;
$attend = $_POST['attend'] ;
$number = $_POST['number'] ;
$lists = $_POST['lists'] ;
$availability = $_POST['availability'] ;
$email = $_POST['email'] ;
$emailaddress = $_POST['emailaddress'];
$fax = $_POST['fax'];
$faxnumber = $_POST['faxnumber'] ;
$mail = $_POST['mail'] ;
$name = $_POST['name'] ;
$street = $_POST['street'];
$city = $_POST['city'] ;
$state = $_POST['state'] ;
$zip = $_POST['zip'] ;
$phone = $_POST['phone'] ;
$comment = $_POST['comment'] ;
$http_referrer = getenv( "HTTP_REFERER" );
$email_body =
'
<html>
<head>
<title>Aarons Creek Farms Tour — Attendance Feedback</title>
</head>
<body>
<table width="554" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td width="534" valign="top" bgcolor="#F4FFFF"> <div align="center">
<h1>Attendance Feedback </h1> </div>
<p> Yes, we will attend lunch ['.$attend.'] </p>
<p> Number attending: '.$number.' </p>
<p>Send price list? ['.$lists.']
<p> Send availability list? ['.$availability.'] </p>
<p> Send by: </p>
<blockquote>
<p> Email ['.$email.'] </p>
<blockquote>
<p> Email address: '.$emailaddress.' </p>
</blockquote>
<p>Fax: ['.$fax.']</p>
<blockquote>
<p> Fax number: '.$faxnumber.' </p>
</blockquote>
<p> Mail: ['.$mail.'] </p>
<blockquote>
<p> Name: '.$name.' </p>
<blockquote>
<p> Street: '.$street.' </p>
<p> City: '.$city.' </p>
<p> State: '.$state.' </p>
<p> Zip: '.$zip.' </p>
</blockquote>
</blockquote>
<p> Phone: '.$phone.' </p>
</blockquote>
<p> Comments: '.$comment.' </p>
</td>
</tr>
</table>
</body>
</html>
';
if(mail($send_to,$subject,$email_body,$additional_headers))
{
echo "Your message was sent. Thank you for contacting us,
we will be in touch shortly.\n";}
else{
echo "Your message could not be sent. Please call our office at the number below\n";
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
I don't think that the Javascript is nessesary at all, in order to refer to the thank_you.html you can look into using something along the lines of meta redirection, or maybe a code like this
I would suggest you validate the info, use something like javascript. In fact d11wtq made an excellent class which will validate wonderfully, its in code snipplets, so check it out..
Code: Select all
<?php
#if info is all validated and sent into you, then create an if statement
if($validated) {
#code to redirect
header("location: http://www.yoursite.com/thank_you.html");
}
else {
header("location: http://www.yoursite.com/your_form.html");
?>feyd | Please use
There's no validation I can see, but I can't really see what fields to require, given the nature of the form, and don't know how else to validate.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Okay, I've been struggling with this all evening. Thanks for bearing with me. I've been trying to understand all the code this time around, but I've had enough of that for one go-round. It's working and I'm not getting out of the boat again tonight. Not sure why this version works, but oh well. All I want to know now is how to change the last little bit so that it will refer to a 'thank-you.htm" page instead of going to a blank screen with plain text.Code: Select all
<?
$send_to = "linda@lkcwebdesign.com";
$recipient = "linda@lkcwebdesign.com";
$subject = "Aarons Creek Farm Tour Feedback";
$additional_headers = "From: linda@lkcwebdesign.com\r\n";
$additional_headers .="Content-type: text/html; charset=iso-8859-1\r\n";
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$fax = $_POST['fax'] ;
$attend = $_POST['attend'] ;
$number = $_POST['number'] ;
$lists = $_POST['lists'] ;
$availability = $_POST['availability'] ;
$email = $_POST['email'] ;
$emailaddress = $_POST['emailaddress'];
$fax = $_POST['fax'];
$faxnumber = $_POST['faxnumber'] ;
$mail = $_POST['mail'] ;
$name = $_POST['name'] ;
$street = $_POST['street'];
$city = $_POST['city'] ;
$state = $_POST['state'] ;
$zip = $_POST['zip'] ;
$phone = $_POST['phone'] ;
$comment = $_POST['comment'] ;
$http_referrer = getenv( "HTTP_REFERER" );
$email_body =
'
<html>
<head>
<title>Aarons Creek Farms Tour — Attendance Feedback</title>
</head>
<body>
<table width="554" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td width="534" valign="top" bgcolor="#F4FFFF"> <div align="center">
<h1>Attendance Feedback </h1> </div>
<p> Yes, we will attend lunch ['.$attend.'] </p>
<p> Number attending: '.$number.' </p>
<p>Send price list? ['.$lists.']
<p> Send availability list? ['.$availability.'] </p>
<p> Send by: </p>
<blockquote>
<p> Email ['.$email.'] </p>
<blockquote>
<p> Email address: '.$emailaddress.' </p>
</blockquote>
<p>Fax: ['.$fax.']</p>
<blockquote>
<p> Fax number: '.$faxnumber.' </p>
</blockquote>
<p> Mail: ['.$mail.'] </p>
<blockquote>
<p> Name: '.$name.' </p>
<blockquote>
<p> Street: '.$street.' </p>
<p> City: '.$city.' </p>
<p> State: '.$state.' </p>
<p> Zip: '.$zip.' </p>
</blockquote>
</blockquote>
<p> Phone: '.$phone.' </p>
</blockquote>
<p> Comments: '.$comment.' </p>
</td>
</tr>
</table>
</body>
</html>
';
if(mail($send_to,$subject,$email_body,$additional_headers))
{
echo "Your message was sent. Thank you for contacting us,
we will be in touch shortly.\n";}
else{
echo "Your message could not be sent. Please call our office at the number below\n";
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Things like phone numbers and email should be validated to an extent. I've developed an mini CMS internally so I had to make sure that numbers and emails were valid because they would be going to a live site once they are entered.
You can use regular expressions to quickly do this.
As akimm already said
Instead of your echos
You can use regular expressions to quickly do this.
As akimm already said
Instead of your echos
if(mail($send_to,$subject,$email_body,$additional_headers))
{
echo "Your message was sent. Thank you for contacting us,
we will be in touch shortly.\n";}
else{
echo "Your message could not be sent. Please call our office at the number below\n";
}
Code: Select all
if($validated && mail($send_to,$subject,$email_body,$additional_headers)){
header("location: http://www.yoursite.com/thank_you.html");
}else{
header("location: http://www.yoursite.com/your_form.html");
}feyd | Please use
Also, the resulting email comes back as html code.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I got an error message when I tried to switch this code
[quote]Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/sisterbecky.com/httpdocs/acf/tour-feedback.php:1) in /var/www/vhosts/sisterbecky.com/httpdocs/acf/tour-feedback.php on line 86[/quote]
I tried commenting out any reference to headers, but go the same message. Here's he code:Code: Select all
<?
$send_to = "linda@lkcwebdesign.com";
$recipient = "linda@lkcwebdesign.com";
$subject = "Aarons Creek Farm Tour Feedback";
//$additional_headers = "From: linda@lkcwebdesign.com\r\n";
//$additional_headers .="Content-type: text/html; charset=iso-8859-1\r\n";
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$fax = $_POST['fax'] ;
$attend = $_POST['attend'] ;
$number = $_POST['number'] ;
$lists = $_POST['lists'] ;
$availability = $_POST['availability'] ;
$email = $_POST['email'] ;
$emailaddress = $_POST['emailaddress'];
$fax = $_POST['fax'];
$faxnumber = $_POST['faxnumber'] ;
$mail = $_POST['mail'] ;
$name = $_POST['name'] ;
$street = $_POST['street'];
$city = $_POST['city'] ;
$state = $_POST['state'] ;
$zip = $_POST['zip'] ;
$phone = $_POST['phone'] ;
$comment = $_POST['comment'] ;
$http_referrer = getenv( "HTTP_REFERER" );
$email_body =
'
<html>
<head>
<title>Aarons Creek Farms Tour — Attendance Feedback</title>
</head>
<body>
<table width="554" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td width="534" valign="top" bgcolor="#F4FFFF"> <div align="center">
<h1>Attendance Feedback </h1> </div>
<p> Yes, we will attend lunch ['.$attend.'] </p>
<p> Number attending: '.$number.' </p>
<p>Send price list? ['.$lists.']
<p> Send availability list? ['.$availability.'] </p>
<p> Send by: </p>
<blockquote>
<p> Email ['.$email.'] </p>
<blockquote>
<p> Email address: '.$emailaddress.' </p>
</blockquote>
<p>Fax: ['.$fax.']</p>
<blockquote>
<p> Fax number: '.$faxnumber.' </p>
</blockquote>
<p> Mail: ['.$mail.'] </p>
<blockquote>
<p> Name: '.$name.' </p>
<blockquote>
<p> Street: '.$street.' </p>
<p> City: '.$city.' </p>
<p> State: '.$state.' </p>
<p> Zip: '.$zip.' </p>
</blockquote>
</blockquote>
<p> Phone: '.$phone.' </p>
</blockquote>
<p> Comments: '.$comment.' </p>
</td>
</tr>
</table>
</body>
</html>
';
if(mail($send_to,$subject,$email_body)){
header("location: http://www.sisterbecky.com/acf/thank-you.html");
}else{
header("location: http://www.sisterbecky.com/acf/error-form.html");
}
// if(mail($send_to,$subject,$email_body,$additional_headers))
//{
// echo "Your message was sent. Thank you for contacting us,
// we will be in touch shortly.\n";}
// else{
// echo "Your message could not be sent. Please call our office at the number below\n";
// }
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]keress wrote:feyd | Please useCode: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color] I got an error message when I tried to switch this code [quote]Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/sisterbecky.com/httpdocs/acf/tour-feedback.php:1) in /var/www/vhosts/sisterbecky.com/httpdocs/acf/tour-feedback.php on line 86[/quote] I tried commenting out any reference to headers, but go the same message. Here's he code:Also, the resulting email comes back as html code.Code: Select all
<? $send_to = "linda@lkcwebdesign.com"; $recipient = "linda@lkcwebdesign.com"; $subject = "Aarons Creek Farm Tour Feedback"; //$additional_headers = "From: linda@lkcwebdesign.com\r\n"; //$additional_headers .="Content-type: text/html; charset=iso-8859-1\r\n"; $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $fax = $_POST['fax'] ; $attend = $_POST['attend'] ; $number = $_POST['number'] ; $lists = $_POST['lists'] ; $availability = $_POST['availability'] ; $email = $_POST['email'] ; $emailaddress = $_POST['emailaddress']; $fax = $_POST['fax']; $faxnumber = $_POST['faxnumber'] ; $mail = $_POST['mail'] ; $name = $_POST['name'] ; $street = $_POST['street']; $city = $_POST['city'] ; $state = $_POST['state'] ; $zip = $_POST['zip'] ; $phone = $_POST['phone'] ; $comment = $_POST['comment'] ; $http_referrer = getenv( "HTTP_REFERER" ); $email_body = ' <html> <head> <title>Aarons Creek Farms Tour — Attendance Feedback</title> </head> <body> <table width="554" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td width="534" valign="top" bgcolor="#F4FFFF"> <div align="center"> <h1>Attendance Feedback </h1> </div> <p> Yes, we will attend lunch ['.$attend.'] </p> <p> Number attending: '.$number.' </p> <p>Send price list? ['.$lists.'] <p> Send availability list? ['.$availability.'] </p> <p> Send by: </p> <blockquote> <p> Email ['.$email.'] </p> <blockquote> <p> Email address: '.$emailaddress.' </p> </blockquote> <p>Fax: ['.$fax.']</p> <blockquote> <p> Fax number: '.$faxnumber.' </p> </blockquote> <p> Mail: ['.$mail.'] </p> <blockquote> <p> Name: '.$name.' </p> <blockquote> <p> Street: '.$street.' </p> <p> City: '.$city.' </p> <p> State: '.$state.' </p> <p> Zip: '.$zip.' </p> </blockquote> </blockquote> <p> Phone: '.$phone.' </p> </blockquote> <p> Comments: '.$comment.' </p> </td> </tr> </table> </body> </html> '; if(mail($send_to,$subject,$email_body)){ header("location: http://www.sisterbecky.com/acf/thank-you.html"); }else{ header("location: http://www.sisterbecky.com/acf/error-form.html"); } // if(mail($send_to,$subject,$email_body,$additional_headers)) //{ // echo "Your message was sent. Thank you for contacting us, // we will be in touch shortly.\n";} // else{ // echo "Your message could not be sent. Please call our office at the number below\n"; // } ?>
feyd | Please useCode: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color][/quote] When you use header, it doesn't like any character sent to the browser. Nor does it like if your <?php is not the absolute first character of your page. Even 1 space before it, will generate that type of error. Side note, must web server will have no problem with <? but some will have issues with it. It is not a must, but a general preference to use the <?php ?> tags when programming with PHP. It is not a must, be some server could give you some issues with it.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Short tag support has been removed in future versions of PHP. It will be a must sooner rather than later.husky_42 wrote:Side note, must web server will have no problem with <? but some will have issues with it. It is not a must, but a general preference to use the <?php ?> tags when programming with PHP. It is not a must, be some server could give you some issues with it.
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
hello
something you must understand before implementing this code, the way you send this mail is very insecure, and quite easily hacked.
I recommend swiftmailer.
however if you still want the help just reply back and i'll help you the best I can.
I recommend swiftmailer.
however if you still want the help just reply back and i'll help you the best I can.