cdoggg94 Posted February 7, 2011 Share Posted February 7, 2011 i want to make a form that has a name, subject, email and comment input box... this is all done and working. the thing i am having trouble with is making the comment box not allow links in it. i thought it would be something like: if("comments" == "<a href=''></a>"){ echo "You have Entered the Wrong Information"; }else{ Insert Record Code.. } the "comments" name is the name of the comment text box. is this anywhere near what it should be ? Link to comment https://forums.phpfreaks.com/topic/226981-form-security/ Share on other sites More sharing options...
AbraCadaver Posted February 7, 2011 Share Posted February 7, 2011 is this anywhere near what it should be ? No. Do you want to strip out the links or just reject the submission? Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171068 Share on other sites More sharing options...
ale8oneboy Posted February 7, 2011 Share Posted February 7, 2011 Are you looking to not allow links/urls at all or just eliminate html tags? You could try 'strip_tags' function after form submit. Take a look at: http://php.net/manual/en/function.strip-tags.php Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171070 Share on other sites More sharing options...
cdoggg94 Posted February 7, 2011 Author Share Posted February 7, 2011 i want to reject the submission all together Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171080 Share on other sites More sharing options...
cdoggg94 Posted February 7, 2011 Author Share Posted February 7, 2011 i have been getting spammed a lot but i dont want to have to make people have to sign up and i thought that maybe disallowing links in that would would be a quick solution Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171082 Share on other sites More sharing options...
AbraCadaver Posted February 7, 2011 Share Posted February 7, 2011 Lot's of ways, maybe: if(stripos($_POST['comments'], '<a ') !== false) { die('Die spammer die!'); } Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171086 Share on other sites More sharing options...
cdoggg94 Posted February 7, 2011 Author Share Posted February 7, 2011 haha ill try that or something similar.. thanks a lot for your help either way Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171088 Share on other sites More sharing options...
cdoggg94 Posted February 7, 2011 Author Share Posted February 7, 2011 it wasnt woking but could something like this have the same type of outcome ? if(stripos($_POST['Comment'], '<a ') == true) { die('Die spammer die!'); } Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171109 Share on other sites More sharing options...
cdoggg94 Posted February 7, 2011 Author Share Posted February 7, 2011 never mind it works fine Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171130 Share on other sites More sharing options...
zenlord Posted February 7, 2011 Share Posted February 7, 2011 Using the filters that come with PHP 5.2, you could validate or sanitize this very easily - they have a check for URL... Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171172 Share on other sites More sharing options...
cdoggg94 Posted February 8, 2011 Author Share Posted February 8, 2011 ill definitely look into it you have been very helpful thanks again Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.