Quote
could someone post an example of having a text box and submit button in html interact with a php?
ps i was wondering if there was a way to filter bad words on it?
OK, example 1:
<!-- HTML -->
<form action="xxx.php" method="post">
<textarea name="data"></textarea>
</form>
<?php
// PHP
if(!empty($_POST['data']))
{
echo nl2br($_POST['data']);
// nl2br used to line break
}
else
{
echo 'Area was empty!';
}
?>
Thats just
basic forms.
Remember to validate
As for bas word filter, thats basic as well. Here's a small function off the top of meh head.
<?php
function filterw ($badW,$text)
{
for ($i=0; $i < count($badW); $i++)
{
$text = str_replace($badW[$i],'****', $text);
}
return $text;
}
$badwords = array (
'insert',
'swear',
'words',
'here'
);
echo filterw($badwords, "insert some text here to test");
?>
Obviously you must expand that from using case insensitive functions like eregi_replace to counting how many letters there are in the bad word and replacing it with that many *****s lol. Even using array values to replace each word with a specific word. Not that hard if you want it but i thought a simple example is best for you.
ps: i have 2/3 ideas as to why your script isn't working, however as deadly said, you need to post it
Edited by .Matt, 27 June 2006 - 02:14 PM.