Jump to content


help with php sig


4 replies to this topic

#1 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 27 June 2006 - 01:41 PM

well i made this php sig awhile ago and just recently transfered servers and now its not working. i was wondering wat might be wrong.

im trying to get the sign.html to interact with add.php but its no long working.

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?

Edited by high6, 27 June 2006 - 01:42 PM.


#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 27 June 2006 - 01:54 PM

post code so we can see

#3 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 27 June 2006 - 02:04 PM

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 :love:

Edited by .Matt, 27 June 2006 - 02:14 PM.


#4 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 27 June 2006 - 02:32 PM

thanks. exactly wat i needed, my error was that i wasnt using $_POST['data']



also when i submit something into my sig like "high's sig." it adds it but as "high\'s sig."

#5 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 27 June 2006 - 03:43 PM

use stripslashes() to get rid of those.

Remember to validate inputs as well, e.g. htmlspecialchars and or striptags etc etc. (just a reminder note lol)

That was why i thought your script wouldn't work. Most servers, rightly so, do not accept the use of just $formname.

Edited by .Matt, 27 June 2006 - 03:44 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users