Jump to content

emailing forms without asp


owen

Recommended Posts

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

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

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

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

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

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

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.

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...