Jump to content


Photo

Shoutbox , ridding SPAM, adding features


  • Please log in to reply
34 replies to this topic

#21 coolaid

coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 29 July 2006 - 06:17 PM

thats because header() needs to be defined before any output code..

heres another alternative

replace the line
header("Location: ".$_SERVER['PHP_SELF']);

with
echo "<meta http-equiv=\"refresh\" content=\"1;". $_SERVER[PHP_SELF] ."\" />\n";


#22 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 29 July 2006 - 06:21 PM

Lol, how can you forget to die. :P
Oh dear, I'm supposed to be dead now. ^_^

Anyways, yes I did 'die'.

if (!$tomanylinks && !$badwordfound) {
			$result = mysql_query("INSERT INTO shoutbox (name, message, time) VALUES ('{$_POST['name']}', '{$_POST['message']}', '$time')") or die(mysql_error());
		}
That's where I put it, since that was the area of problem (plus I found no other actual querys I could legally put it in).

Also coolaid's totally right about the output. I run into that all the time when I'm trying to redirect or set some cookies. Drives me nuts sometimes, since I always link something to my index page with the include nav, so it kind of already sends the headers before hand. I've had to work around that as well.

#23 kevinoneill

kevinoneill

    Young Padawan

  • Members
  • Pip
  • 61 posts

Posted 29 July 2006 - 06:24 PM

Hey Coolaid, yup put that in there, and it clears up the "send data" again deal. But it loads the page twice everytime i submit... little annoiying for users. Anyway around that?

#24 coolaid

coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 29 July 2006 - 08:29 PM

well you can try this, i just cut the delay:
echo "<meta http-equiv=\"refresh\" content=\"0;". $_SERVER[PHP_SELF] ."\" />\n";


#25 kevinoneill

kevinoneill

    Young Padawan

  • Members
  • Pip
  • 61 posts

Posted 29 July 2006 - 08:32 PM

Yaeh I tried changing the content to 0 too, still does it. I know i've seen shoutboxes that post automatically with out reloading, wonder how that's done.

#26 Matthew.

Matthew.

    Official Spammer .Matt

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

Posted 29 July 2006 - 08:37 PM

If you dont want the page to change when posting you could use an iframe (NOOO DON'T DO IT lol) or the better way is to ajax it up a bit which is a bit more confusing. Of course with ajax you can also check for new shouts without refreshing the page which is always handy. (that would just be using setinterval which you have already shown)

oh and coolaid, why not just add ob_start() at the top of the page instead of using meta refresh?

#27 coolaid

coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 29 July 2006 - 08:38 PM

heh, probably with iframes....

i'm working on one that's doing it with ajax, but thats a little beyond what you want probably, too much to do...

****
edit

i wouldn't use ob_start() cause last time i tried to use it i failed horribly.... ^_^

Edited by coolaid, 29 July 2006 - 08:39 PM.


#28 kevinoneill

kevinoneill

    Young Padawan

  • Members
  • Pip
  • 61 posts

Posted 29 July 2006 - 08:41 PM

Actually that's probally exactly what I want. Hey I got a Q. Is this AJAX stuff, new? I'm getting the feeling its like XHTML, just javascript + html.

Does AJAX have a whole new programming language? or is it just a neat term for php+html+javascript? AJAX is basically pulling data from a db live, hence not refreshing a page.

#29 coolaid

coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 29 July 2006 - 08:44 PM

ajax - asynchonized javascript and xml...


basically its javascript to load and return the results of another webpage and only reload a piece of the page the viewer is looking at... in it's simplest form i guess.

#30 Matthew.

Matthew.

    Official Spammer .Matt

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

Posted 29 July 2006 - 08:46 PM

lol, how did it fail??

Ajax is just javascript. It uses php/html etc etc the list goes on to whatever language you are using with it. The majority of it is javascript. It's not knew.

There is a section on it here: http://www.pixel2lif...avaScript/AJAX/

edit: wo0, 2nd same time post ina row coolaid, we're one role ^_^

Edited by .Matt, 29 July 2006 - 08:47 PM.


#31 kevinoneill

kevinoneill

    Young Padawan

  • Members
  • Pip
  • 61 posts

Posted 29 July 2006 - 08:47 PM

that is pretty much exactly what i thought it was. Would make wonders as far as menu's are concerned. I wanna know more!!! hehe So what kinda coding are we talking abou there?

#32 coolaid

coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 29 July 2006 - 08:52 PM

lol, how did it fail??


i have no idea, i tried using it in my template system to hold uhhh.. display info but it would display it before i wanted it to! i jus didn't bother with it....

soo uhh.. whats this thread about again??.. oh yea... wait... hmmm...
^_^

so yea.. ajax with xhtml and php would work...

#33 kevinoneill

kevinoneill

    Young Padawan

  • Members
  • Pip
  • 61 posts

Posted 29 July 2006 - 08:54 PM

haha why am i so excited?

Found this example.
http://www.dynamicdr...ajaxcontent.htm

I'm about ready to redo my site using this ^_^

Yeah, AJAX shout box would rule!!!

#34 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 30 July 2006 - 01:18 PM

(output started at /home/irekevin/public_html/index2.php:1)

You probably have a line break at the top of the file. Make sure the opening <?php is the FIRST thing in the file (no spaces, no line breaks, nothing).

If you want to have an AJAX shoutbox, remember that people can simply turn JavaScript off, and they wouldn't be able to use it. Plus there's XBC you have to worry about. It would be awesome if you could pull it off, but AJAX is not for the less experienced.

Edited by rc69, 30 July 2006 - 01:22 PM.


#35 kevinoneill

kevinoneill

    Young Padawan

  • Members
  • Pip
  • 61 posts

Posted 31 July 2006 - 01:39 PM

Well all in all thank you for all your help.

I did manage to find this.

yurivish.com/yshout/

Which I implemented and am looking forward to version 3.

I'm also redoing my whole site and using some AJAX such as this

irekevin.com/ajaxcars/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users