Page 1 of 1

[SOLVED]How to exclude some words - from FORM before query

Posted: Wed Jan 28, 2004 3:28 pm
by Calimero
If an user enters wirds in a textfield, what is the code for removing predefined words (I make a list and script searches it, if a word is found to be excluded it is not passed on to a query.

ALSO how do I make some word defined for logical operators - AND, OR , NOT, how to tell the script what to do if it finds them

Posted: Wed Jan 28, 2004 3:47 pm
by Derfel Cadarn
Have you tried it yourself or do you want us to code it for you??

Posted: Wed Jan 28, 2004 3:59 pm
by ol4pr0
I wouldnt have a clue i only know that

Code: Select all

READONLY TABINDEX="-1
Will disable the text field

I would need help from the expirienced one :)

Posted: Thu Jan 29, 2004 1:28 am
by Calimero
Derfel Cadarn
Programmer>

I am very new to PHP, so the code would be VERY helpful, I'm still learning, but .... Some basic things I still havent grasped.

IF someone has the time for the code, THANKS, I would realy apreciate it.

:?

Posted: Thu Jan 29, 2004 2:00 pm
by Derfel Cadarn
Calimero wrote:Derfel Cadarn
Programmer>
Yeah, well, euhhh I just got that title automatically by writing more than 100 postings in this forum. It has nothing to do with my (in)abilities... :lol:
Check out Volka with 5000 postings or so... :oops:

But back to your problem: I don't have the code ready for you, but I think a method of how to solve the problem could be of some help, perhaps?

Assuming you know HTML and a BIT of PHP:
1. write the form with the textfield (name=textfield).
2. <form action="posting.php" method="post" blahblah>.

The posting.php-script needs to do something like this:
1. define an array containing the forbidden words.
2. read the text the visitor has written as a whole with $_POST[textfield].
3. with the function [php_man]split[/php_man] you can split the text into an array containing the words (split the text at each space).
4. And now: [php_man]foreach[/php_man] word in the array compare it with the words in the array with the forbidden words: if the same then delete the words from text.

I know this sounds very complicated, perhaps I didn't explain it too well either. But this is the method I'd use.

Success!! :D