cancel
Showing results for 
Search instead for 
Did you mean: 

PHP Problems

frinholp
Newbie
Posts: 3
Registered: ‎11-04-2008

PHP Problems

Hi
I am currently trying to create a website that allows a user to obtain a quote by sending me their details using a form that calls a PHP script. The script should generate an email to myself containing details of the quote.
I continue to get the following error:-
405 Method Not Allowed
e3
Method Not Allowed
The requested method POST is not allowed for the URL /quote.php.
0
Here is the code:-

<?php
$mailto = 'bookings@deejays.plus.com' ;
$subject = "Booking Form" ;
$formurl = "http://www.deejays.plus.com/quote.html" ;
$errorurl = "http://deejays.plus.com/error.html" ;
$thankyouurl = "http://www.deejays.plus.com/quotecomplete.html" ;
$uself = 0;
$email_is_required = 1;
$name_is_required = 1;

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$email_required = (!isset( $email_is_required ) || ($email_is_required == 0)) ? 0 : 1 ;
$name_required = (!isset( $name_is_required ) || ($name_is_required == 0)) ? 0 : 1 ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (($email_required && (empty($email) || !ereg("@", $email))) || ($name_required && empty($name))) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (empty($email)) {
$email = $mailto ;
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.10.0" );
header( "Location: $thankyouurl" );
exit ;
?>

Any ideas?
Thanks in advance
6 REPLIES 6
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: PHP Problems

You can't use php on the homepages server, it has to go on the ccgi server.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: PHP Problems

Can't you use http://www.plus.net/support/webspace/cgi_php/cgi_scripts.shtml instead of rolling your own?
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
frinholp
Newbie
Posts: 3
Registered: ‎11-04-2008

Re: PHP Problems

Quote
You can't use php on the homepages server, it has to go on the ccgi server.

Cheers Jelv
Do I need to upload just the php script to the ccgi server and link to it or the whole website?
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: PHP Problems

Just the php file. It's looking good with what you have done.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
frinholp
Newbie
Posts: 3
Registered: ‎11-04-2008

Re: PHP Problems

Yeah I got it sorted. I should of put my brain in gear before my mouth and  tested before asking silly questions.
Got your test email Jelv.
Cheers again.
Have a problem now that if the the file is filled incorrectly I recieve this error when the content of error.html should be displayed:-
Web Server Error Report:
Server Error: 501 Not Implemented
No RPM for this combination of URL and method
/error.html
????
I'm new to html and scripting you see, although I can program a little in C and Java.
Trying to debug now
Prod_Man
Grafter
Posts: 287
Registered: ‎04-08-2007

Re: PHP Problems

Right,
You've put the PHP Script on the CCGI Server,
and not put "error.html" (according to the error described) in the Root of the CCGI Space,
of course it won't show an error because the file doesn't exist. Smiley
Another solution is to use Header Redirection, and back that up with a HTML Redirect on the page just incase of poor browser HTTP response handeling:

...
Header('Location: www.deejays.plus.com/success.html');
echo '
<META HTTP_EQUIV = "REFRESH" CONTENT = "2; url=http://www.deejays.plus.com/success.html">';
...

I'd check out alittle on FORM's and HTTP Protocol so you understand (if you don't already) the difference in Packet Structure of a HTTP Request especially reguarding "GET" and "POST" Method Variables / Values in PHP.
(PHP Predefined Arrays for GET / POST Variables: $_GET[] / $_POST[] Member names from "NAME" Field in HTML)
As you could have the Form on your WWW Space that just utilises the CCGI Space and swiftly returns the user to the WWW Space with your other HTML Files it would appear relatively seemless.

...
Header('Location: www.deejays.plus.com/success.html');
...

Be careful where you place these,
as you cannot send Header Directives after you've echoed/printed for output.


echo 'Hello';
...
Header('Location: www.deejays.plus.com/success.html');
...

is a big no no. PHP will tell you as well / the script might cry Smiley
Nice to know you've used other programming languages of a similar style,
that helps 90% of the time Smiley
C - is good,
Java - not so good in my opinion xD but what ever floats your boat.
Hope some of that helps!
Jim,