Page 1 of 1
PHP code to edit a page from a page
Posted: Wed Apr 07, 2010 7:40 am
by dash2nash
Hi,
I'm new here, I mean real new, just registered like 5mins ago, anw, I'm an undergrad and working as freelance. Ok I got some problem, well actually not a problem, but meh...
I got a project where there will be an admin page, which can edit the actual page. So I can edit the actual page on the admin page (just the content of the some part of course). I manage to show the content, what I don't know is how can I put it back to the actual pages?
(well don't call me noob if this problem is just so simple, coz I'm actually a noob)
Thx anw
Re: PHP code to edit a page from a page
Posted: Wed Apr 07, 2010 8:57 am
by ell0bo
You need to explain this a little better? Are you using a database in the backend to store the dynamic parts of the page? Are you directly editing the pages on the server via this form?
Re: PHP code to edit a page from a page
Posted: Wed Apr 07, 2010 9:36 am
by dash2nash
I'll be using example,
A as actual page, B as editing / admin page
So I'll be editing the A from a form in B, I don't need any database to store it, I'm using div to separate each part.
Is it a bit better?
Re: PHP code to edit a page from a page
Posted: Wed Apr 07, 2010 10:01 am
by ell0bo
That is just a bad idea. If you want to do something like that, just use DreamWeaver or the sort. If you are allowing apache to edit the web pages it presents, you're opening yourself up to a whole bunch of security issues.
Re: PHP code to edit a page from a page
Posted: Wed Apr 07, 2010 10:16 am
by dash2nash
Well, the thing is, the client wants that he can edit the content of the page itself, so I don't think he can work out the things in DreamWeaver, i can't get any other ideas other than that. Regarding the security issues, well actually it just a 1 ppl-own website, so I don't see any issues in it (i'm assuming that the issues you told me earlier was a page edited by 2 persons?). Or do you have any other ideas?
Re: PHP code to edit a page from a page
Posted: Wed Apr 07, 2010 12:07 pm
by ell0bo
Well, the security issue stem from any page that the web server is able to serve also being editable by the server. If someone, somehow, managed to compromise your server, they would be able to change the pages just using the user the server is running as. Generally speaking, that's just a bad idea.
However, the way I would recommend doing it would be to change values in a database, and then dynamically add that content to the page. For instance if they simply want to be able to change the text on some element, you present that text in a textarea, and then dynamically add the text via PHP.
Essentially, what you want is WYSIWYG editor, and I've never heard of one that will edit the actual files on the server. You can create a template, and then allow the user to populate those templated areas with whatever text they want.
Re: PHP code to edit a page from a page
Posted: Thu Apr 08, 2010 3:44 am
by dash2nash
Yeah I got what you mean, I read some stuffs bout WYSIWYG editor can you like give me a brief explanation on how to use it?
Re: PHP code to edit a page from a page
Posted: Thu Apr 08, 2010 7:11 am
by ell0bo
Well... a quick google gave me these
http://www.lmgtfy.com/?q=open+source+WYSIWYG .
Essentially, what you'd have to do is export the html created by the WYSIWYG to a template file, and then include that using a PHP file to deliver the page.
so... index.php would be
<?php
include ('/templates/some_template.tmp');
You WYSIWYG would push the HTML out and save that to /templates/some_template.tmp;
Now, that's similar to what you wanted to do, however it's not the way I would do it, but it would work and it doesn't give you a major security problem.
I myself would break the page into objects and store those in the DB, but that's only because that's how my framework works. I unfortunately don't have a WYSIWYG part tied into the framework, so I can't give you that as an example right now.