Sponsor for PC Pals Forum

Author Topic: Refresh webpage with php?  (Read 2841 times)

Offline Hiatus

  • Regular Member
  • **
  • Posts: 193
    • JoshSalverda.com
Refresh webpage with php?
« on: March 27, 2006, 23:17 »
Is there a way to refresh a webpage using PHP?

I'm trying to get the page to refresh every 2 seconds or so, but the problem is there are textboxes and I don't want to lose the text when it is refreshed... I think I have done this before, I just don't remember how...

What I'm trying to do is make a chatroom using php and mysql... I don't even know if it's possible to do it the way I'm attempting to, but we'll soon find out, lol... so far I have it so users can log in, choose a "board" they want to chat on, then send messages to the board... all the messages are stored in the mysql database and just written to the screen... the only problem im having so far is refreshing the page w/o losing the text... any help would be great...
l33t h@x0r... sort of...

Offline Hiatus

  • Regular Member
  • **
  • Posts: 193
    • JoshSalverda.com
Refresh webpage with php?
« Reply #1 on: March 27, 2006, 23:30 »
Awesome, nevermind I just found out how to refresh the page using a META tag

Code: [Select]

<META HTTP-EQUIV=Refresh CONTENT="3; URL=http://www.yoursite.com/yoururl.php">


That will refresh the page every 3 seconds which works perfectly... but I'm still losing the text in the input boxes...
l33t h@x0r... sort of...

Offline Simon

  • Administrator
  • *****
  • Posts: 76533
  • First to score 7/7 in Quiz of The Week's News 2017
Refresh webpage with php?
« Reply #2 on: March 28, 2006, 09:51 »
I used to find that with Internet Explorer, but with Firefox / Mozilla you don't lose the text when you refresh.  :?
Many thanks to all our members, who have made PC Pals such an outstanding success!   :thumb:

Offline AdamBoyle

  • New Member
  • *
  • Posts: 7
Refresh webpage with php?
« Reply #3 on: March 29, 2006, 15:19 »
Hey, im sorry for my long absense :)

Quote from: "Simon"
I used to find that with Internet Explorer, but with Firefox / Mozilla you don't lose the text when you refresh.  :?


Right, PHP :) Ive just finished writing my ICT coursework using PHP so lets hope we can come up with something...

Could you give me some more information please? Are you loosing the text stored in the database? Or the text stored in the textbox being used to enter text? If the text box is part of a form (ie. within the open and close form tags) then you will be able to use $_POST to read the value that was submitted. In theory.

Just in summary: Using a mySQL database while the system is small wont cause too much lag on page loading. Once there are 500 or 1000 messages, with new ones constantly being added, the load will become noticable...

Offline Hiatus

  • Regular Member
  • **
  • Posts: 193
    • JoshSalverda.com
Refresh webpage with php?
« Reply #4 on: March 31, 2006, 01:57 »
I don't know if I described this properly before. I was talking to my friend about it a couple nights ago, and he said that it's more like a "shoutbox" which describes it a lot better. Basically, a user posts messages to a constantly updating page/frame.

Quote from: "AdamBoyle"
Could you give me some more information please? Are you loosing the text stored in the database?


No, the text in the database is fine.

Quote from: "AdamBoyle"
If the text box is part of a form (ie. within the open and close form tags) then you will be able to use $_POST to read the value that was submitted. In theory.


Yes, the text is part of a form. I didn't think a $_POST statement would work for this as the page reloads every three seconds. I don't know how to explain in words why it wouldn't work, but in my head I can see that i won't...

Quote from: "AdamBoyle"
Just in summary: Using a mySQL database while the system is small wont cause too much lag on page loading. Once there are 500 or 1000 messages, with new ones constantly being added, the load will become noticable...


I hope not to have more than 500 messages displayed all at once. I'm going to try to figure out a way to remove the earliest messages as the board starts to get to 100 lines or more.

Anyways, I think I've figured out a way to accomplish (mostly) everything I want. I'm going to use an iframe in which all the messages will be displayed. That way I can just update the iframe without losing any text in the textbox. Hopefully that should work. :?
l33t h@x0r... sort of...


Show unread posts since last visit.
Sponsor for PC Pals Forum