Re: Coding for email response forms

From: Date: Mon, 26 Jan 2009 22:35:37 +0000
Subject: Re: Coding for email response forms
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-287189@lists.php.net to get a copy of this message
Shawn McKenzie wrote: > > Tom Scott wrote: >> ----- Original Message ----- From: "Shawn McKenzie" >> <nospam@mckenzies.net> >> Newsgroups: php.general >> To: <php-general@lists.php.net> >> Sent: Monday, January 26, 2009 3:52 PM >> Subject: Re: [PHP] Coding for email response forms >> >> >>> Tom wrote: >>>> "Shawn McKenzie" <> wrote in message >>>> news:A0.87.62571.3D92E794@pb1.pair.com... >>>>> Tom wrote: >>>>>> My Hosting site said that I needed to include the PHP otherwise >>>>>> the form >>>>>> won't work. I need to know where to include my email info to get >>>>>> this set >>>>>> up >>>>>> don't I? What do you suggest? >>>>>> T >>>>>> "Daniel Brown" <danbrown@php.net> wrote in message >>>>>> >>>>>> news:ab5568160901261259p6d6442a4ya5ea4134025e5f50@mail.gmail.com... >>>>>>> On Mon, Jan 26, 2009 at 15:57, Tom <obelix16@comcast.net> wrote: >>>>>>>> I am a new user of PHP, and am using Dreamweaver CS3 for the >>>>>>>> webpages. >>>>>>>> The >>>>>>>> following page has my form but the submit button is not working >>>>>>>> properly. >>>>>>>> >>>>>>>> http://www.richlandmtg.com/contacts.html >>>>>>>> What code is needed and where does it get placed in the page.? I >>>>>>>> thought >>>>>>>> CS3 >>>>>>>> took care of this. >>>>>>> Tom, >>>>>>> >>>>>>> This issue has nothing at all to do with PHP. This is all client >>>>>>> side (JavaScript and HTML). >>>>>>> >>>>>>> -- >>>>>>> </Daniel P. Brown> >>>>>>> daniel.brown@parasane.net || danbrown@php.net >>>>>>> http://www.parasane.net/ || >>>>>>> http://www.pilotpig.net/ >>>>>>> Unadvertised dedicated server deals, too low to print - email me >>>>>>> to find >>>>>>> out! >>>>> What you have now is a form that when submitted sends the data to >>>>> itself. So you either need to include some php in this file to gather >>>>> up the data and email it when submitted, or submit to another file >>>>> that >>>>> does that. >>>>> >>>>> >>>>> -- >>>>> Thanks! >>>>> -Shawn >>>>> http://www.spidean.com >>>> Shawn, >>>> So would that look something like this: >>>> <? >>>> if ($_SERVER['REQUEST_METHOD'] == "POST") { >>>> >>>> // Just to be safe, I strip out HTML tags >>>> $realname = strip_tags($realname); >>>> $email = strip_tags($email); >>>> $feedback = strip_tags($feedback); >>>> >>>> // set the variables >>>> // replace $me@mysite.com with your email >>>> $sendto = "$me@mysite.com"; >>>> $subject = "Sending Email Feedback From My Website"; >>>> $message = "$realname, $email\n\n$feedback"; >>>> >>>> // send the email >>>> mail($sendto, $subject, $message); >>>> >>>> } >>>> ?> >>>> >>>> >>>> >>> Oh, you should also think about some other things, such as validation. >>> Is realname only alpha characters? Is email in the form of a real email >>> address? At a bare minimum, are they not empty: >>> >>> if (empty($_POST['email']) || >>> empty($_POST['realname']) || >>> empty($_POST['feedback'])) >>> { >>> echo 'You must complete all required fields!'; >>> // show form again >>> } >>> >>> >>> -- >>> Thanks! >>> -Shawn >>> http://www.spidean.com >> Ok. I have the validation part. >> http://www.richlandmtg.com/index-5.html still working on >> the Send button. >> >> T >> >> > Please reply all so this stays on the list. > > 1. In the source for your link I see that the JS is doing some validation. > 2. You have method="get" in your form. This will work, but you'll have > to change the PHP code to use $_GET instead of $_POST vars. Or change > to method="post" in the form. > 3. If you want to keep the .html extension for the page, then you'll > probably need to send the post to another script with a .php extension. > Normally a file with a .html extension won't execute the PHP code. > > Thanks! > -Shawn > > >

« previous php.general (#287189) next »