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 ? Quote 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? Quote 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 Quote 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 Quote 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 Quote 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!'); } Quote 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 Quote 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!'); } Quote 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 Quote 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... Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/226981-form-security/#findComment-1171218 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.