Connecting Tech Pros Worldwide Forums | Help | Site Map

updating an html page via a php script

dave
Guest
 
Posts: n/a
#1: Jul 17 '05
Hello,
I've got a page, actually a friend does, that he'd like to update with
his schedule for the week. THis is a simple html page, and he'd like to do
this via a php script. Ideally one would load the page, see a current week
schedule if any, or nothing if there is none, and be able to add events.
This should be as simple as possible and not require a database for this is
simple text entry. I've fofilled part of this, i can open the index file,
and write information to it, but i'm not sure how to lock the file so
simultaneous writes can not occur and i do not know how o place the
information in a specific area.
Any help appreciated.
Thanks.
Dave.



jn
Guest
 
Posts: n/a
#2: Jul 17 '05

re: updating an html page via a php script


"dave" <dmehler26@woh.rr.com> wrote in message
news:HC36c.23585$8G2.11451@fe3.columbus.rr.com...[color=blue]
> Hello,
> I've got a page, actually a friend does, that he'd like to update with
> his schedule for the week. THis is a simple html page, and he'd like to do
> this via a php script. Ideally one would load the page, see a current week
> schedule if any, or nothing if there is none, and be able to add events.
> This should be as simple as possible and not require a database for this[/color]
is[color=blue]
> simple text entry. I've fofilled part of this, i can open the index file,
> and write information to it, but i'm not sure how to lock the file so
> simultaneous writes can not occur and i do not know how o place the
> information in a specific area.
> Any help appreciated.
> Thanks.
> Dave.
>
>[/color]

Store the text in a text file, and use a script to edit the contents of the
text file.

Then instead of having a plain HTML page display the data, create it as a
PHP page and include() the text file where ever the schedule goes. Or you
can just use a server-side include in a normal HTML page if it is supported.

You can even use flock() to keep multiple people from editing it at the same
time.


Chung Leong
Guest
 
Posts: n/a
#3: Jul 17 '05

re: updating an html page via a php script



Uzytkownik "jn" <usenet*spamistehsuckremovetoreply*@jasonnorris.ne t> napisal
w wiadomosci news:eh46c.257839$B81.3581425@twister.tampabay.rr. com...[color=blue]
> "dave" <dmehler26@woh.rr.com> wrote in message
> news:HC36c.23585$8G2.11451@fe3.columbus.rr.com...
> Store the text in a text file, and use a script to edit the contents of[/color]
the[color=blue]
> text file.
>
> Then instead of having a plain HTML page display the data, create it as a
> PHP page and include() the text file where ever the schedule goes. Or you
> can just use a server-side include in a normal HTML page if it is[/color]
supported.[color=blue]
>
> You can even use flock() to keep multiple people from editing it at the[/color]
same[color=blue]
> time.[/color]

You can't keep a file lock between requests, so flocking won't prevent
multile people from editing the same file. To do that you'd need to
implement your own file-based locking mechanism, or go poke around PHP's
session files.

You can also approach the problem this way: Save the md5 of the file in a
session variable, then check the md5 of the file again before overwriting it
with the submitted content. If the md5s don't match, the user gets a error
message, telling him/her that someone has modified the file.


dave
Guest
 
Posts: n/a
#4: Jul 17 '05

re: updating an html page via a php script


Hello,
Thanks, i thought of that. I can't rename pages, or do anything with
ssi's even though that would be easiest. I need to have like an input area
on a form, where text is entered, then when a submit button is pushed the
information is written to the indicated file. But i'm not sure how to get
the information to a specific place in the file.
Thanks.
Dave.


Žed Eye Media - Richard Grove
Guest
 
Posts: n/a
#5: Jul 17 '05

re: updating an html page via a php script



"dave" <dmehler26@woh.rr.com> wrote in message
news:otc6c.24728$8G2.24385@fe3.columbus.rr.com...[color=blue]
> Hello,
> Thanks, i thought of that. I can't rename pages, or do anything with
> ssi's even though that would be easiest. I need to have like an input area
> on a form, where text is entered, then when a submit button is pushed the
> information is written to the indicated file. But i'm not sure how to get
> the information to a specific place in the file.
> Thanks.
> Dave.
>
>[/color]

You need to have some server side stuff.
Ideally PHP enabled webspace.
Very easy of you have this.

Ricgard Grove
http://shopbuilder.org


Garp
Guest
 
Posts: n/a
#6: Jul 17 '05

re: updating an html page via a php script



"dave" <dmehler26@woh.rr.com> wrote in message
news:HC36c.23585$8G2.11451@fe3.columbus.rr.com...[color=blue]
> Hello,
> I've got a page, actually a friend does, that he'd like to update with
> his schedule for the week. THis is a simple html page, and he'd like to do
> this via a php script. Ideally one would load the page, see a current week
> schedule if any, or nothing if there is none, and be able to add events.
> This should be as simple as possible and not require a database for this[/color]
is[color=blue]
> simple text entry. I've fofilled part of this, i can open the index file,
> and write information to it, but i'm not sure how to lock the file so
> simultaneous writes can not occur and i do not know how o place the
> information in a specific area.
> Any help appreciated.
> Thanks.
> Dave.[/color]

He should start with a proper database, and stop trying to write one from
scratch (which is what he's doing). Sooner or later, he's going to find more
useful things to do with it and he'll end up rewriting bucket loads of code
to handle databases instead of fiddling with text files and permissions.
It's not even difficult, and it's a skill he can re-use over and over.

Garp



Closed Thread