owen Posted March 2, 2006 Share Posted March 2, 2006 HiI'm trying to set up a subscription to a mailing list button on a website. I've checked and the host server doesn't seem to support asp.What do i need to do to get a text box to to send it's contents to an email address?Please help Link to comment Share on other sites More sharing options...
real_illusions Posted March 2, 2006 Share Posted March 2, 2006 if it supports php then your fine.theres quite a few php mailing scripts out there:) Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 Another way to do it is with a cgi script. If you send it directly to your email you won't be able to read it. With cgi you'll format the data from your form and send it to your email. Your host should support cgi scripts. Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 HiThanks for the advice, i tried looking at CGI scripts last night from Matts script archive but i couldn't understand any of it. I've found a simple PHP script but it seems to be causing problems still.The html of the form goes like this:<FORM METHOD="post" ACTION="sendmail.php"> <INPUT Name="email" type="text" value="Email address" size="30"/> <INPUT TYPE="submit" class="submitbutton" VALUE="Join the Onk" alt="subscribe to mailing list" /> </FORM>And the php - sendmail.php goes like this:<? $email = $_REQUEST['email'] ; mail( "owen@owenrimington.co.uk", "Feedback Form Results", "From: $email" ); header( "Location: http://www.madrugada-parties.co.uk/new/index.html" ); ?>When i use the post method the browser says method not allowed and when i use the get method the browser says page cannot be found?????? Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 I believe the method should be post but I have no idea with it says not allowed. Is it the page with your form or sendmail.php that gives you the "method not allowed" error? Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 In the address bar it says it has gone to the php page.It says 405 method not allowed Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 I've checked on Google and I found one solution: Resolving 405 errors - general405 errors often arise with the POST method. You may be trying to introduce some kind of input form on your Web site, but not all ISPs allow the POST method necessary to process the form.All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP.I haven't seen that error before so I can't really help you but Google is your friend Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 Cheers I'll have a look. Do you know if can use the 'get' method in this situation? Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 I don't think so... I've only used the get method with a cgi script.Weclome for the help Link to comment Share on other sites More sharing options...
aspnetguy Posted March 2, 2006 Share Posted March 2, 2006 You can use the GET method for any HTML form no matter what scripting language you use to process it. The data will get passed in the url.if you are using PHP you would get the data like this.Say one of your fields in the form is named 'firstname' the get method will send the data in the url like thisyourpage.php?firstname=somevalueThen in PHP the variable name would be $firstname instead of using $_POST['firstname']. PHP grabs querystring into varaibles for you names the same as in the url. Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 I don't think so... I've only used the get method with a cgi script.Weclome for the help <{POST_SNAPBACK}> Sorry to keep bothering you but is there an easy way to use CGI script, i haven't got a clue and it's driving me a bit mad Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 You can use the GET method for any HTML form no matter what scripting language you use to process it. The data will get passed in the url.if you are using PHP you would get the data like this.Say one of your fields in the form is named 'firstname' the get method will send the data in the url like thisyourpage.php?firstname=somevalueThen in PHP the variable name would be $firstname instead of using $_POST['firstname']. PHP grabs querystring into varaibles for you names the same as in the url.<{POST_SNAPBACK}> Hi aspnetguySorry you lost me a bit there. could you have a look at php posted above and tell me how it needs to change. i haven't used $_POST anywhere in the script. I'm new to all this. Thanks for your help Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 I found this script here that could help you to process your form easily. It's got great review. You need to download the script. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 2, 2006 Share Posted March 2, 2006 ok I did a bit of reading. I am new to PHP too. It is recommended that you use $_POST to get data sent via the post method and $_GET to get data from the get method (makes sense).$_REQUEST is not as secure as those other mothods so from what I understand you shouldn't use it.So if you change your form method to GET you should replace $_REQUEST with $_GET in the script above. Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 The reason why $_REQUEST is not secure is because for example if I have http://localhost/mysite.php?id=1 and I do $_REQUEST of id then my value is 1. That means anyone who simply adds ?id=1 after the url will be able to access the page and submit the form. With $_GET or $_POST, they get the inputs from the form that was submitted. Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 Cheers Guys Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 Hi That link to the cgi thing didn't work, it kept failing when you pressed the download button. I've gone back to PHP here is a new script<?// $mailto - set to the email address you want the form// sent to, eg//$mailto = "youremailaddress@example.com" ;$mailto = 'owen@owenrimington.co.uk' ;// $subject - set to the Subject line of the email, eg//$subject = "Feedback Form" ;$subject = "ONK" ;// the pages to be displayed, eg//$formurl = "http://www.example.com/feedback.html" ;//$errorurl = "http://www.example.com/error.html" ;//$thankyouurl = "http://www.example.com/thankyou.html" ;$formurl = "http://www.madrugada-parties.co.uk/index.html" ;$errorurl = "http://www.madrugada-parties.co.uk/error.html" ;$thankyouurl = "http://www.madrugada-parties.co.uk/thankyou.html" ;$uself = 0;// -------------------- END OF CONFIGURABLE SECTION ---------------$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;$name = $_GET['name'] ;$email = $_GET['email'] ;$comments = $_GET['comments'] ;$http_referrer = getenv( "HTTP_REFERER" );if (!isset($_GET['email'])) { header( "Location: $formurl" ); exit ;}if (empty($name) || empty($email) || empty($comments)) { header( "Location: $errorurl" ); exit ;}if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ;}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.07" );header( "Location: $thankyouurl" );exit ;?>Still doesn't work though Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 Sorry about that. At home I think I still have a CGI script to process forms. It's really simple but it's been so long since I did that. I could always send it to you? Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 Sorry about that. At home I think I still have a CGI script to process forms. It's really simple but it's been so long since I did that. I could always send it to you?<{POST_SNAPBACK}> That would be amazing, cheers Link to comment Share on other sites More sharing options...
vchris Posted March 2, 2006 Share Posted March 2, 2006 Cool. So I'll send you the code when I get home. Should be in ~3 hours. Link to comment Share on other sites More sharing options...
owen Posted March 2, 2006 Author Share Posted March 2, 2006 Thanks alot Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now