Jump to content

Prevent URL's in form submission


wmckinn

Recommended Posts

Hello,

I have very little experience with php, and would like some advice.

 

I need a way to prevent URL's from being inserted into form fields. I have not been able to discover how to do this. Our forms are being submitted with junk URL's in the form fields. I would like to either A) Kill the form processing if URL's are posted, or B) Provide a pop up message stating that URL submissions are not allowed.

 

Does anyone have any ideas? :)

 

Thanks,

Walt

Link to comment
https://forums.phpfreaks.com/topic/41447-prevent-urls-in-form-submission/
Share on other sites

create a check function that runs onSubmit of the form, it checks the strings from the forms and parses them through the function to see if a url is present, if so it returns false, if not it returns true, lets call out function checkurl().

 

function checkurl($string)
{
// Stuff that spammers post with:
$bad_strings = array('www.','/url]','ttp://','ttps://') ;
foreach( $bad_strings as $bad_string )
{
if ( ereg( $bad_string, $string ) )
{ 
return false ;
}
else
{
return true;
}
}
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.