Page 1 of 1

PHP Shoutbox help

Posted: Sat Apr 30, 2005 1:14 am
by Raven-flock
Alright i made a php shout box but now i want to make it so it refreshes but only way i can think of it without messing up the text box everytime someone tries typing.. i want it to refresh every 15 seconds..... and only way i know how to do that is to put the shout box into a frame and the text boxes out of the frame unless someone else knows different.. and plus i want to make it where when they login to my site it logs them into the shout box so they dont have to keep typing there username and stuff can someone help me with this please... and i was just wondering if someone could show me how to make it where when a users logs online it takes them from a offline table to an online table or something like that so i can make it where it says which users are online............

Thank you
Raven-Flock

here are the scripts...(Didnt want to feel this place up alot)

http://www45.brinkster.com/shoutbox2032/login.html

http://www45.brinkster.com/shoutbox2032/shout.html[/url]

Posted: Sat Apr 30, 2005 8:29 am
by Chris Corbyn
Read about XMLHTTP.... that will do exactly what you need.

It's essentially just a bit of a "fancy javascript" which can communicate to the server and just update the parts of the page you need.

To be honest, I'm only just egtting around to learning XMLHTTP myself :oops:

Posted: Sat Apr 30, 2005 5:23 pm
by Raven-flock
i dont want to put XMLHTTP on there i want it like i said... i want it to be in a frame and a message box on the out side of the frame........

...

Posted: Sat Apr 30, 2005 6:03 pm
by Calimero
Ok, the problem for me is - that I didn't "quite" understood what you need, but here is the solution for what I understood ( my version :) )

If you need to preserve everything ( this shout-box ) - sorry I don't know the exact translation - not native english speaker, use JavaScript, and PHP/MySQL in this way:

Put the text-area or a form element in the page - that will not change, use frame or iframe and refresh it in the desired interval ( or maybe on user submit - when he/she enters some text in the field )

Use JavaScript code in the main page to:
- Start the timer,
- When it ticks 15 sec's or the button is clicked
- Submit the frame or iframe I mentioned
- And when it loads retreive the data from it.
- And then just ADD data(records) to the text-area or text-box

This requires PHP/MySQL - server counterpart:
You can use 2 ways to transfer data - GET, POST - I recommend POST - create little form in the frame/iframe, submit it and let PHP process the data.

When processed they must be stored in a manner that JavaScript can use them later - easiest: blank page with one form and one textfield, and every new record in that field, comma ( or some special sign ) delimited. JavaScript can easily refference it.

In JavaScript use "location.replace", not "location.href" for submiting the frame/iframe - so when user clicks BACK button, it gets the page it was before, not reload the frame/iframe.

Hope this helps.

Posted: Sat Apr 30, 2005 7:46 pm
by Raven-flock
i already have a php shout box all i need is someone to help me find away to put it in a frame or a iframe and make my login script work with the shout box script

Posted: Sun May 01, 2005 5:16 am
by shiznatix
make a table with 2 cells
in the cell you want to be your iframe(were you show your messages)

Code: Select all

<iframe name='frameA' width='100%' height='100%' src='show_messages.php'></iframe>
in show_messages.php have a meta refresh set for 15 seconds so the show_messages.php will automatically refresh itself inside the iframe.

then on the other cell of your table have the html form where you can do the remember me option, the username, and the message, and whatnot.

as for the login part have where it logs into the shotbox

Code: Select all

if (isset($_SESSION['logedIn']))
{
    //make the user able to type into the shoutbox
}
else
{
    //show login screen and make sure after the user logs in to set a session
}
is that the answers you needed?

Posted: Sun May 01, 2005 6:43 pm
by Raven-flock
not really i know how to do the frame part but only thing is that i dont know how to divide my shout box script up because everything works with everything when i make a frame for it and put it the codes in it screws up.....