View Full Version : Website Alerter
Trigs
25-05-2008, 10:15 PM
I need to code an alerter script that can alert everyone who is currently viewing my site in real time. A javascript alert would do.
How should I do that, and no i'm not asking for the script, i'm asking how to do it and what I should use so don't flame me (which happens to about 97% of the people who ask questions on here).
--ss--
26-05-2008, 12:36 PM
Well you'll have to have an frame/section of the site that automatically refreshes automatically (Eg the radio stats or any other flatfiles that will be put onto the main page from an external page). You would have to then open the page , add the javascript alert code to the flatfile and when the frame reloads automatically the alert would be popped up , then you could re edit the file and remove it.
That's the only basic and logical way that I can think off doing it :(.
Jackboy
26-05-2008, 12:48 PM
ajax...
Dentafrice
26-05-2008, 12:59 PM
Send an AJAX request to a file ex: viewAlerts.php
in viewAlerts.php it connects to the database, and checks for messages
it returns the message to the Javascript or returns 0 if there isn't any. If it returns a message, PHP will set a cookie/session for that EX: $_SESSION['alert_' . $id];
Javascript checks to see if it was 0, if else it was a message.. and it alerts it.
Protege
26-05-2008, 03:51 PM
I don't see why'd you need to set a session?
Florx
26-05-2008, 04:03 PM
So you don't keep getting the alert every time the AJAX requests the page.
Dentafrice
26-05-2008, 04:07 PM
I don't see why'd you need to set a session?
You could also set a cookie.
Independent
26-05-2008, 07:58 PM
You could also set a cookie.
Mmm.. Cookies!
Why would you use both, thats just a waste of code.
Protege
26-05-2008, 07:59 PM
I never thought of that.
Trigs
26-05-2008, 08:05 PM
Thanks Dent, ill try it out
Dentafrice
26-05-2008, 09:09 PM
Mmm.. Cookies!
Why would you use both, thats just a waste of code.
I meant or you can set a cookie.
I never thought of that.
How would you do it?
Bonxy
26-05-2008, 10:55 PM
if you can make these website alerters PM me. ill pay for a decent one
Invent
26-05-2008, 11:16 PM
Bonxy, why have you ripped http://www.puhekupla.com/?
Bonxy
26-05-2008, 11:24 PM
Bonxy, why have you ripped http://www.puhekupla.com/?
huh ?
got to do with ??
Invent
26-05-2008, 11:26 PM
I was going to offer to code the thing for you but noticed you ripped that site. If you had told me you got permission to use the layout or something I was going to offer to code the script (:
Dentafrice
26-05-2008, 11:29 PM
Ripping is bad.
Invent accept me to the group dear purty please. xx :)
Protege
26-05-2008, 11:48 PM
I was basically doing it the same way as you - But I never thought of setting a cookie/session, maybe cause I've never actually done one to see the result.
Dentafrice
26-05-2008, 11:50 PM
Yeah, if you don't log it somewhere, either the IP or the session_id, then compare the alert to one of those.. it is going to show everytime for the user :P
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.