Hi,
I have a form that's getting spammed with links.
I'd like to have the form not submit if links (or any other html is present)
Not sure where to start here. I know I can get a field's content, but not sure how to check if html is present.
Anyway, that would stop the spammers I think?
Thanx for your help
Mark
I have a form that's getting spammed with links.
I'd like to have the form not submit if links (or any other html is present)
Not sure where to start here. I know I can get a field's content, but not sure how to check if html is present.
Anyway, that would stop the spammers I think?
Thanx for your help
Mark
Hi Mark,
It's late now so only a very quick reply. Please see this FAQ for a partial answer. You can probably find a regular expression to apply that would pick up most HTML tags.
Bob
It's late now so only a very quick reply. Please see this FAQ for a partial answer. You can probably find a regular expression to apply that would pick up most HTML tags.
Bob
That did it - thanx Bob!
Posted my solution below (custom server side validation in "on submit" towards the top - the code in the faq has a minor error by the way:
Posted my solution below (custom server side validation in "on submit" towards the top - the code in the faq has a minor error by the way:
if ( strpos($form->data['input_textarea_5'], $v) !== false ) {
<?php
$ban_array = array(
'http',
'www',
'.com'
);
$isvalid = true;
foreach ( $ban_array as $v ) {
if ( strpos($form->data['input_textarea_5'], $v) != false ) {
$form->validation_errors['input_textarea_5'] = 'Sorry, I do not allow links in this contact form. Please remove any links and try again.';
return false;
}
}
?>
Hi Mark,
If the 'minor error' is the !== then it isn't. The PHP Manual says:
Bob
If the 'minor error' is the !== then it isn't. The PHP Manual says:
Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.
Bob
This topic is locked and no more replies can be posted.