Re: Newbie php problem



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!
.



Relevant Pages

  • Re: Newbie php problem
    ... Please forget the first part of the script, as I do put some extra ... accepting input, ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ...
    (alt.php)
  • Re: Web programming: issues with large amounts og data
    ... script appearing to freeze. ... portions of the (Perl) code. ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ... merchants is the presently commented out code is uncommented and the ...
    (comp.lang.perl.misc)
  • Re: Any way PHP can directly initiate/execute a HTTP connection+download?
    ... various online tutorials I had been using to teach myself PHP ... So I wrote a test script that does the ini_get and shows me the ... That could mean either that the free PHP/MySQL hosting ... PHP script on shell account back to PHP script on free hosting ...
    (comp.lang.php)
  • Re: Newbie php problem
    ... Please forget the first part of the script, as I do put some extra ... in the header, and it'll make the rest of the checking easier following ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ...
    (alt.php)
  • Re: sanitizing uploaded data with a form
    ... i'm escaping quotes for the database, but i wasn't sure what other ... If the script is to display them, ... especially someone else on the server, if you use a shared server and ... Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers ...
    (alt.php)