Re: Newbie php problem
- From: Tim Greer <tim@xxxxxxxxxxxxx>
- Date: Wed, 07 Jan 2009 13:13:48 -0800
Floor wrote:
I have written a simple php script that handles sending form content
to a recipient.
My problem is, that allthough I check behavior on form fields,
sometimes an empty form shows up. I think this is due to the fact that
someone runs the php script by hand (spiders?). To avoid this, I am
looking for a way of breaking out running the php script as soon as
one of the $_POST[xxxx] contains spaces or nothing at all. So the
mail($to....) line should be skipped. Can someone hint me out on this?
Thanks in advance...
Example script, header fields etc deleted:
<?php
$to = "Me <me@xxxxxxxxxxxxx>";
$subject = "Request from $_POST[Name]";
$message = "There has been a request
$_POST[Name]
$_POST[Adress]
$_POST[Postcode] $_POST[Town]
";
mail($to, $subject, $message);
?>
-- Floor
You probably want to evolve that script, but for the immediate problem,
why not have a form field that's a hidden HTML tag, which is a specific
value, and the script only executes the mail function if (for example)
the field name "mailed" is "wassubmitted" or any combination you wish
to use, and only then is is submitted. Also, you should probably check
that certain fields exist, before you allow the mail() function to be
used. After all, even a normal person submitting the form should fill
in specific fields if you want to receive it. Again, you will want to
use a more advanced method for this overall, but that should prevent
anyone from just submitting blank information or any spam bots or
search engines (for the most part with spam bots) regarding your
current script.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
.
- Follow-Ups:
- Re: Newbie php problem
- From: Beauregard T. Shagnasty
- Re: Newbie php problem
- References:
- Newbie php problem
- From: Floor
- Newbie php problem
- Prev by Date: Newbie php problem
- Next by Date: Re: Updated PHP 5 - curl init error
- Previous by thread: Newbie php problem
- Next by thread: Re: Newbie php problem
- Index(es):
Relevant Pages
|