Ive created a website, and added a php contect page (code was given to me by a friend, who the code works for). This code will now not work on my site, can anyone have a look and tell me whats wrong? the address is http://www.chrisgreen-designs.cjb.net , then click contact on the top right-and side. Cheers if you can help. p.s. if it makes any difference though I dont think it does, im hosting it on telewest blueyonder, but im sure they support php.
First off, I don't have any experience with PHP, but look at the error message you are getting: The requested method POST is not allowed for URL /ChrisGreen-designs/files/sendmail.php If you haven't already, try changing the form method to get: <form name="form1" method="get" action="sendmail.php">
can you post the code of the sendmail.php? heres a example of the script i use PHP: <?php /* Paul's Email Script */ function error_message($msg) { echo "<script>alert(\"Error: $msg\");history.go(-1)</script>"; exit; } function user_message($msg) { echo"<script>alert(\"$msg\");history.go(-1)</script>"; exit; } function send_mail() { global $mail_name, $mail_email, $mail_website, $mail_subject, $mail_comments; $mail_parts["mail_name"] = $mail_name; $mail_parts["mail_email"] = $mail_email; $mail_parts["mail_website"] = $mail_website; $mail_parts["mail_subject"] = $mail_subject; $mail_parts["mail_comments"] = $mail_comments; if (my_mail($mail_parts)) user_message("Successfully sent and email titled '$mail_subject'."); else error_message("An unknown error occurred while attempting to send an email titled '$mail_subject'."); } function my_mail($mail_parts) { // only part you need to edit! $mail_to = "youremail@domain.com"; //end editing $mail_name = $mail_parts["mail_name"]; $mail_email = $mail_parts["mail_email"]; $mail_website = $mail_parts["mail_website"]; $mail_subject = $mail_parts["mail_subject"]; $mail_comments = $mail_parts["mail_comments"]; if(empty($mail_name)) error_message ("Empty Name field!"); if(empty($mail_email)) error_message ("Empty Email field!"); if(empty($mail_subject)) error_message ("Empty Subject field!"); if(empty($mail_comments)) error_message ("Empty Comments field!"); $mail_to = str_replace(";", ",", $mail_to); $mail_headers = ''; if(!empty($mail_email)) $mail_headers .= "From: $mail_email\n"; if(!empty($mail_email)) $mail_headers .= "Reply-to: $mail_email\n"; $mail_subject = stripslashes($mail_subject); $mail_comments = stripslashes ($mail_comments); $mail_body .= "Name: $mail_name\n"; $mail_body .= "Email: $mail_email\n"; $mail_body .= "Website: $mail_website\n\n"; $mail_body .= "Subject: $mail_subject\n\n"; $mail_body .= "Comments: $mail_comments\n"; $mail_comments = $mail_body; return mail($mail_to,$mail_subject,$mail_comments,$mail_headers); } switch ($action) { case "send_mail": send_mail(); mail_form(); break; case "mail_form": mail_form(); break; default: mail_form(); break; } function mail_form() { global $PHP_SELF; ?> <form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="send_mail"> <p>Please use the below form to contact me about anything that you may please, also please note that spammers will be reported to their isp. <br> </p> <table width="49%" border="0" align="center" class="content-text"> <tr> <td width="26%" valign="middle"> Name: </td> <td width="74%"> <input name="mail_name" type="text" size="30" maxlength="30"> </td> </tr> <tr> <td valign="middle"> Email: </td> <td> <input name="mail_email" type="text" size="30" maxlength="50"> </td> </tr> <tr> <td valign="middle"> Website: </td> <td> <input name="mail_website" type="text" size="30" maxlength="50"> </td> </tr> <tr> <td valign="middle"> Subject: </td> <td> <input name="mail_subject" type="text" size="30" maxlength="50"> </td> </tr> <tr> <td valign="top"> Comments: </td> <td> <textarea name="mail_comments" cols="30" rows="5" id="textarea"></textarea> </td> </tr> <tr> <td valign="top"> </td> <td> <input name="send" type="submit" id="send" value="Submit"> <input name="Reset" type="reset" id="Reset" value="Reset"> </td> </tr> </table> </form> <?php } ?> if you post the code of ur script we will help you out
Here is the form code <form action="sendmail.php" method="post" name="contact" target="_blank"> <br> <table width="75%" border="0"> <!--DWLayoutTable--> <tr> <td width="122" height="24" class="NoLinkText">Name:</td> <td colspan="3"><input name="form_name" type="text" id="form_name" size="40"></td> </tr> <tr> <td height="24" valign="top" class="NoLinkText">E - Mail address:</td> <td colspan="3" valign="top"><input name="form_mail" type="text" id="form_mail" size="40"></td> </tr> <tr> <td height="24" valign="top" class="NoLinkText">Subject:</td> <td colspan="3" valign="top"><input name="form_subject" type="text" id="form_subject" size="40"></td> </tr> <tr> <td height="104" valign="top" class="NoLinkText">Message:</td> <td colspan="3" valign="top"><textarea name="form_message" cols="40" rows="5" id="form_message"></textarea></td> </tr> <tr> <td height="30" colspan="2" align="right" valign="middle"> <div align="right"> <input name="cmdSubmit" type="submit" id="cmdSubmit" value="Submit"> </div></td> <td width="1"> </td> <td width="238" align="left" valign="middle"><input name="cmdClear" type="reset" id="cmdClear" value="Clear"></td> </tr> <tr> <td height="3"></td> <td width="112"></td> <td></td> <td></td> </tr> </table> </form></td> Here is the sendmail.php code <?php $mailsubject = "ChrisGreen-designs Query"; $mailheader = "From: $form_mail"; $msgp = "Dear Chris Green"; $msgp = "Subject:"; $msgp = "$form_subject"; $msgp = "Message:"; $msgp = "$form_message:"; $msgp = "From:"; $msgp = "$form_Name"; $msgp = "E-Mail:"; $msgp = "$form_Mail"; $form_email_address = "ChrisGreen-designs@blueyonder.co.uk"; mail($form_email_address, $mailsubject, $msgp, $mailheader); ?> if it makes any difference, the php tags and all the text in the quotes is in red (im presuming this is an error)
have u had the script working before? try this PHP: <?php $form_email_address = "ChrisGreen-designs@blueyonder.co.uk"; $mailsubject = "ChrisGreen-designs Query"; $mailheader = "From: $form_mail"; $msgp .= "Dear Chris Green\n\n"; $msgp .= "Subject:\n"; $msgp .= "$form_subject\n\n"; $msgp .= "Message:\n"; $msgp .= "$form_message:\n\n"; $msgp .= "From:\n"; $msgp .= "$form_Name\n\n"; $msgp .= "E-Mail:\n"; $msgp .= "$form_Mail\n\n"; $mail_comments = $msgp; mail($form_email_address, $mailsubject, $mail_comments, $mailheader); ?> you really want to put in some validation into the script, to make sure people fill it up properly use correct email addresses and so on, havent had time to test it so it it doesnt work sorry, if you like u can edit mine to fit into ur site
Ive tried changing the code to that which you suggested in the previous post, and it didnt work. So i tried using your code, and changing just the email addy2 start with (as if it worked i could add the page layout ect after) ad that didnt work either. Im starting to struggle now, and my assignment (the creation of this website) is due in on thursday edit: ive never had the script working, but my teacher who gave me it (and wrote it) says that it works fine. Could it be a problem with blueyonder? Though ive looked and they support php i think. must check again!!
well im not sure about the script u got fae ur teacher but the one i posted works fine, and i have been using it for a year or so without any problems, let me test the one i posted for you. ok mate, just tested that one that i changed from your original it works fine, must be ur server, so heres what to do, on this line PHP: <form action="sendmail.php" method="post" name="contact" target="_blank"> change to PHP: <form action="http://www.fcuked-up.co.uk/scripts/sendmail.php" method="post" name="contact"> taking away the target="_blank" will stop popping up another window, and allow the javascript to let people know the message was sent successfully that will work the form i used was the one u supplied with no edits, and the code in the sendmail.php is as below PHP: <?php $form_email_address = "paul@fcuked-up.co.uk"; $mailsubject = "ChrisGreen-designs Query"; $mailheader = "From: $form_mail"; $msgp .= "Dear Chris Green\n\n"; $msgp .= "Subject:\n"; $msgp .= "$form_subject\n\n"; $msgp .= "Message:\n"; $msgp .= "$form_message:\n\n"; $msgp .= "From:\n"; $msgp .= "$form_name\n\n"; $msgp .= "E-Mail:\n"; $msgp .= "$form_mail\n\n"; $mail_comments = $msgp; mail($form_email_address, $mailsubject, $mail_comments, $mailheader); ?> <script>alert("Mail Sent Successfully");history.go(-1)</script> if u need to contact for more help and want a quicker reply get me at http://www.fcuked-up.co.uk/modules/contact/index.php hope that helps u out
HELLO! Look at the error message you are getting: The requested method POST is not allowed for URL /ChrisGreen-designs/files/sendmail.php If you haven't already, try changing the form method to get: <form name="form1" method="get" action="sendmail.php"> All the examples above have the form method "POST"
the phenom is on the job. i will let you know about what I get!! (Even though my PHP Server is on my busted Comp.) Quickly, do you know about register_globals??? Your host may have them turned off!!
Ok try this: PHP: <?php $form_email_address = "ChrisGreen-designs@blueyonder.co.uk"; mail ($form_email_address, $_REQUEST[form_subject],$_REQUEST[form_message], "From: $_REQUEST[form_mail]"); } ?> have the form as the following: PHP: <form action="sendmail.php" method="post" name="contact">
the scripts i posted work, you can try them at http://www.fcuked-up.co.uk/scripts/email.php and my own one at http://www.fcuked-up.co.uk/modules/contact/index.php they do work as i have tested them
OK the problem has been sorted. I think it was down to blueyonder not playing fair, but ive followed there tutorial on form mail and my contact page is now working. Thanks for all your help.