PDA

View Full Version : PHP form


Len Whistler
04-26-2003, 09:25 PM
Hello Everyone:

I have a feedback form at http://www.stubby.ca/contact.htm that doesn't work. The PHP code is below and I get an error on line 8 message. Both the .php file and the form .htm file are in the same directory as my index.htm page.

Also when I work with a .php file in Notepad amd try and save it with the .php extension the .txt extension also gets added, example: feedback.php.txt


Thanks

Leonard Whistler
www.stubby.ca



<?
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl = "http://www.stubby.ca/contact.htm");
exit ;
}
if (empty($name) || empty($email) || empty($comments))
{
header( "Location: $errorurl = "http://www.stubby.ca/error.htm");
exit ;
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS
-------------------------\n\n" .
$comments .

"\n\n------------------------------------------------------------\n"
;

mail($mailto = 'lwhistler@yahoo.com', $subject = "Feedback Form", $messageproper, "From:
\"$name\" <$email>\nReply-To: \"$name\"
<$email>\nX-Mailer: chfeedback.php 2.01" );
header( "Location: $thankyouurl = "http://www.stubby.ca/thankyou.htm");

Spookster
04-26-2003, 09:43 PM
You should always post what the error is other wise we cannot help you easily. But I will take a guess and say that maybe your error looked something like:

"Warning: Cannot add header information - headers already sent by..."

?????


As for saving php files in notepad you need to change the Save as Type box to All Files or surround your filename with quotes like this "test.php" .

Spookster
04-26-2003, 09:47 PM
Ok just noticed you had posted a URL so I can see the error now. You have a parse error on line 8. You will probably also have parse errors on at least 2 other lines as well. Here is the one on line 8:

header( "Location: $formurl = "http://www.stubby.ca/contact.htm");

In all of your lines of code where you are sending a header with the URL you have an out of place quotation mark in there. Take out that quotation mark.

Len Whistler
04-26-2003, 09:50 PM
Thanks Spookster:


This a great forum, and I have had lots of help in the past from the members.

Also thanks for the .php saving in notepad tip.


Leonard Whistler
www.stubby.ca