For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2006 > PHP Problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PHP Problem
DG

2006-07-20, 6:57 pm

Please bear with me, I'm VERY new at this....here is the problem:

We have a very simple comment form on our website that uses a PHP file to
mail the results to one of our email addresses. We found out a few days ago
that when trying to submit a comment there was a box popping up asking for
username, password, domain. I called our ISP who hosts our site and they
looked in to it (the tech said he thought someone else called about the same
thing). When they called back they said they fixed the popup for username,
etc., but they were now getting the following message "CGI Error. The
specified CGI application misbehaved by not returning a complete set of HTTP
headers." I tried it and got the same message. My ISP recently switched
their mail server and the new one requires SMTP Authentication. They also
said they just upgraded to PHP 5.1.4. They feel my problem is with my PHP
file. It worked before all of these recent changes but I don't know exactly
when it stopped working to try to tie it to any of these changes. Could
someone give me advice if the SMTP Authentication or their upgrade to PHP
5.1.4 is the problem and how would I fix it?

Here is the PHP we are using (someone was kind enough to share this with me,
I am not the composer):



<?
/*
Comment Form

*/


$mailto = 'OUR EMAIL ADDRESS' ;

$subject = "Questions or Comments Submitted via Website" ;


$formurl = "FORM URL" ;
$errorurl = "ERROR MSG URL" ;
$thankyouurl = "THANKS MSG URL" ;


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

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email)) {
header( "Location: $errorurl" );
exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

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

"Name: $name\n" .
"City: $city\n" .
"State: $state\n" .
"Email: $email\n" .


"------------------------- COMMENTS -------------------------\n\n" .


$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper, "From: \"$name\"
<$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php
2.04" );
header( "Location: $thankyouurl" );
exit ;

?>


Flamer

2006-07-25, 6:56 pm


DG wrote:

> Please bear with me, I'm VERY new at this....here is the problem:
>
> We have a very simple comment form on our website that uses a PHP file to
> mail the results to one of our email addresses. We found out a few days ago
> that when trying to submit a comment there was a box popping up asking for
> username, password, domain. I called our ISP who hosts our site and they
> looked in to it (the tech said he thought someone else called about the same
> thing). When they called back they said they fixed the popup for username,
> etc., but they were now getting the following message "CGI Error. The
> specified CGI application misbehaved by not returning a complete set of HTTP
> headers." I tried it and got the same message. My ISP recently switched
> their mail server and the new one requires SMTP Authentication. They also
> said they just upgraded to PHP 5.1.4. They feel my problem is with my PHP
> file. It worked before all of these recent changes but I don't know exactly
> when it stopped working to try to tie it to any of these changes. Could
> someone give me advice if the SMTP Authentication or their upgrade to PHP
> 5.1.4 is the problem and how would I fix it?
>
> Here is the PHP we are using (someone was kind enough to share this with me,
> I am not the composer):
>
>
>
> <?
> /*
> Comment Form
>
> */
>
>
> $mailto = 'OUR EMAIL ADDRESS' ;
>
> $subject = "Questions or Comments Submitted via Website" ;
>
>
> $formurl = "FORM URL" ;
> $errorurl = "ERROR MSG URL" ;
> $thankyouurl = "THANKS MSG URL" ;
>
>
> $name = $_POST['name'] ;
> $city = $_POST['city'] ;
> $state = $_POST['state'] ;
> $email = $_POST['email'] ;
> $comments = $_POST['comments'] ;
> $http_referrer = getenv( "HTTP_REFERER" );
>
> if (!isset($_POST['email'])) {
> header( "Location: $formurl" );
> exit ;
> }
> if (empty($name) || empty($email)) {
> header( "Location: $errorurl" );
> exit ;
> }
> $name = strtok( $name, "\r\n" );
> $email = strtok( $email, "\r\n" );
> if (get_magic_quotes_gpc()) {
> $comments = stripslashes( $comments );
> }
>
> $messageproper =
>
> "This message was sent from:\n" .
> "$http_referrer\n" .
>
> "Name: $name\n" .
> "City: $city\n" .
> "State: $state\n" .
> "Email: $email\n" .
>
>
> "------------------------- COMMENTS -------------------------\n\n" .
>
>
> $comments .
> "\n\n------------------------------------------------------------\n" ;
>
> mail($mailto, $subject, $messageproper, "From: \"$name\"
> <$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php
> 2.04" );
> header( "Location: $thankyouurl" );
> exit ;
>
> ?>


Hello, problem is on th ephp configuration side of things, basically if
your hosts mail server requires authenitcation for sending mail (smtp)
then a username and password has to be supplied, now the user
submitting the form can't supply this it has to be apache. make a new
php file and put this in it <?php phpinfo(); ?> open it in a browser,
have a look down at smtp settings, does it say localhost for the server
name or something else, i suspect it says something else, in this case
go tell your host to fix their apache config to supply
username/password to the mail server.

Flamer.

Colin McKinnon

2006-07-26, 6:57 pm

DG wrote:

> Please bear with me, I'm VERY new at this....here is the problem:
>
> We have a very simple comment form on our website that uses a PHP file to
> mail the results to one of our email addresses. We found out a few days
> ago that when trying to submit a comment there was a box popping up asking
> for
> username, password, domain.


This is kind of weird - rather than try to work out why your email script is
doing this, I think it's time to write a "hello world" script and see how
it behaves.

> I called our ISP who hosts our site and they
> looked in to it (the tech said he thought someone else called about the
> same thing). When they called back they said they fixed the popup for
> username, etc., but they were now getting the following message "CGI
> Error. The specified CGI application misbehaved by not returning a
> complete set of HTTP
> headers."


Never heard of this either. Any idea which webserver they are running on?
I've always found PHP to be very good at this kind of thing. Anyway, I
don't believe a CGI program is required to return any http headers.

> I tried it and got the same message. My ISP recently switched
> their mail server and the new one requires SMTP Authentication. They also
> said they just upgraded to PHP 5.1.4. They feel my problem is with my PHP
> file. It worked before all of these recent changes but I don't know
> exactly when it stopped working to try to tie it to any of these changes.
> Could someone give me advice if the SMTP Authentication or their upgrade
> to PHP 5.1.4 is the problem and how would I fix it?
>


Stop worrying about the SMTP authorization - yes, it's going to stop your
script from working as intended, but you've got other problems to solve
first.

HTH

C.

DG

2006-07-28, 6:57 pm


"Colin McKinnon"
<colin.thisisnotmysurname@ntlworld.deletemeunlessURaBot.com> wrote in
message news:OCQxg.31485$i32.22333@newsfe2-gui.ntli.net...
> DG wrote:
>
>
> This is kind of weird - rather than try to work out why your email script
> is
> doing this, I think it's time to write a "hello world" script and see how
> it behaves.
>
>
> Never heard of this either. Any idea which webserver they are running on?
> I've always found PHP to be very good at this kind of thing. Anyway, I
> don't believe a CGI program is required to return any http headers.
>
>
> Stop worrying about the SMTP authorization - yes, it's going to stop your
> script from working as intended, but you've got other problems to solve
> first.
>



Thank you! The "hello world" script behaved exactly the same (CGI error) so
I called my ISP. They have now fixed the problem and the comment form is
working again. Thanks again!!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com