Jump to content
Sign in to follow this  
Dragon_12dk

PHP Filter / Sanatization

Recommended Posts

Hello,

I have recently been attempting to make HTML forms in my website filtered by PHP strings... I have a PHP Filter that should work, However I am not sure on how to Integrate it into my HTML forms. Here is what I have right now...

 

HTML Form

<h3>Add Site Manual</h3><div class="addurlSmall">Enter the Site Title, Url and Description you want to add, it will automatically add it in the database</div><br /><?php require 'BannedWords.php';?><form action="/index.php?a=admin" method="post"><div class="">	Site Title: <input type="text" name="addtitle" value="" required /><br />	Site URL: <input type="url" name="addurl" value="http://" required /><br />	Site Description: <br /><textarea lass="ads" name="adddesc" required></textarea></div><br /><input type="submit" value="Add new result"/></form>

PHP Filter.

<?php$ban_array = array(  'Bad',  'Words',  'Here');$input_array = array (  'adddesc',  'addurl',  'addtitle');$isvalid = true;foreach ( $ban_array as $v ) {  foreach ( $input_array as $vv ) {    if ( strpos($form->data[$vv], $v) !== false ) {      $form->validation_errors[$vv] = 'Banned words in use!!';      return false;    }  }}?>

Any help would be appreciated :) Thanks.

Share this post


Link to post
Share on other sites

That code needs to run when the form has been submitted and is being processed. Hopefully you have other code that defines the $form object.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...