wmckinn Posted March 6, 2007 Share Posted March 6, 2007 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 More sharing options...
paul2463 Posted March 6, 2007 Share Posted March 6, 2007 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; } } } Link to comment https://forums.phpfreaks.com/topic/41447-prevent-urls-in-form-submission/#findComment-200786 Share on other sites More sharing options...
wmckinn Posted March 6, 2007 Author Share Posted March 6, 2007 Thank you; I'll give this a try! Walt Link to comment https://forums.phpfreaks.com/topic/41447-prevent-urls-in-form-submission/#findComment-200807 Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 Thank you; I'll give this a try! Walt you may also want to add TLD's to the array such as .com, .net, .us, .biz, .org, ect...... Link to comment https://forums.phpfreaks.com/topic/41447-prevent-urls-in-form-submission/#findComment-200833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.