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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

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

Post 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
Last edited by Calimero on Fri Jun 25, 2004 5:38 am, edited 1 time in total.
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Have you tried it yourself or do you want us to code it for you??
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I wouldnt have a clue i only know that

Code: Select all

READONLY TABINDEX="-1
Will disable the text field
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

I would need help from the expirienced one :)

Post 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.

:?
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post 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
Post Reply