You are here: Form Validatioin « All PHP « IT news, forums, messages
Form Validatioin

Posted by Brian on 04/23/06 04:15

Hi

I have been having a lot of trouble of late with somebody trying to use my
form script to send Spam.

I have tried to lock them out but they keep changing IP address and I can't
so
I have removed following line to stop the emails, but I still get crap
though

$headers .= "From:$Email <$Contact_Name>\n";

So I am now going to have to look at a better way of Form Validation

I found this script on the net to validate the email address, seem to work
fine (see below)

I now want to add two extra things

First, apart from the email address all the other fields are either string,
numbers or a combination,
they should never have anything else that, below is an example of what I am
getting through,
what's the best way to stop this?

counthry Content-Type: multipart/alternative;
boundary=244c370b70207220fc95267404de5752 MIME-Version: 1.0 Subject: s bcc:
bressg6@hotpop.com This is a multi-part message in MIME
format. --244c370b70207220fc95267404de5752 Content-Type: text/plain;
charset=\"us-ascii\" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit in th
shape iv an advance payment on th dowry. t fifteen quit stoppin runaway
horses as on y suited to childher. fter that wint in almost entirely f r
knockin down arnychists as they was about to shoot.
saved --244c370b70207220fc95267404de5752-- .

Second, can anybody point me in the right direction to add one of those
things where the user has to type in a number, but the number is shown as a
distorted graphic I'm guessing I need to set a cookie or something and they
test for it when the user types in the number. It there a graphic library to
do this?

Thanks

Brian



function checkaddaddress($email) {
// First, we check that there's one @ symbol, and that the lengths are
right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section,
or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i <sizeof($local_array); $i++) {
if
(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain
is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) <2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i <sizeof($domain_array); $i++) {
if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$",
$domain_array[$i])) {
return false;
}
}
}
return true;
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация