Jump to content

Editing Web Content


misterivanovich

Recommended Posts

You have all helped immensely in building my user login code for my admin area... And now I have to attempt to build said admin area!Now, I'm sure all I have to do is find a way to extract all of the content from a given .php file and make it into a variable, then stuff it back into the .php file when I'm done editing it... But I have no idea how to do this! Should I be storing my content on my MySQL databases so I can recall it in both the admin area for editing and the regular sites for viewing?Also, I would like to incorporate some buttons to make editing a little easier for the people here that don't know the first thing about HTML. I want to have them click a button and have a pop up dialogue box tell them to enter the URL then the text for any links they want, then tell them to enter URLs for pictures they want to put up, and have a button to click to create italicized, bolded or underlined text. Basically, just really simple stuff that I don't know how to make buttons for.Don't suppose I could get some help on this bit here too?

Link to comment
Share on other sites

Do a Google search for a rich text editor, you'll find plenty of them already built. I don't know what you're talking about with extracting the content of a PHP file into a variable, but the file_get_contents function will return the contents of a file in a string. If you want to execute the PHP file instead of reading it, you will want to use include or require instead.

Link to comment
Share on other sites

Do a Google search for a rich text editor, you'll find plenty of them already built. I don't know what you're talking about with extracting the content of a PHP file into a variable, but the file_get_contents function will return the contents of a file in a string. If you want to execute the PHP file instead of reading it, you will want to use include or require instead.
What I meant by setting the content equal to a variable is something like... This, I guess.
$variable = "This would be the string of content on any given page.";**Pretend I inserted a textarea named newvariable with a POST method form.  The original text in this textarea is $variable.**$variable = $_POST['newvariable'];

You know? That way, you could easily take all the text on a page and change it. I suppose by using the file_get_contents function I could just take everything from the <body> tag to the </body> tag and then edit it that way - however, I wouldn't know how to put the NEW text or information back into the .php file. Is there a file_update_content function or something?

Link to comment
Share on other sites

Well, you can use file_put_contents if you have PHP5 to write a file. That doesn't update though, it replaces the file with whatever you give it. But rather then trying to write the updated page content to files, it would be a lot easier if you wrote the content to a database, and had a page that would look up content from the database and display it on the page. That way you don't have to screw around with parsing an HTML file looking for the content.

Link to comment
Share on other sites

Should I be storing my content on my MySQL databases so I can recall it in both the admin area for editing and the regular sites for viewing?
So that would be a yes?Should I consider it a large piece of text, or do I not even have to specify that? Can I just insert some text in there and call it a day?
Link to comment
Share on other sites

When you set up the table you have to say what the data type of each field is. For something like that you will want to use the text data type. For smaller pieces of text, like a username or password, you would just use a varchar type, but those are limited to 255 characters. A text field can hold 64kb I think.

Link to comment
Share on other sites

When you set up the table you have to say what the data type of each field is. For something like that you will want to use the text data type. For smaller pieces of text, like a username or password, you would just use a varchar type, but those are limited to 255 characters. A text field can hold 64kb I think.
The text that's stored in there can include HTML, correct? So I could just echo whatever I pull out of the database and it would parse it just as it has been by pulling it out and echoing everything? Just making sure. =PAlso, by eliminating the use of external websites to hold the information, how would I use my links? Would I have everthing just do GET variable links and work with it that way? Say, for instance...If I wanted to visit a page on woodshop, I could do index.php?p=wood as the link, and whatever the query is that pulls information out and displays it would be something like mysql_query(display_table($_GET['p'])), yeah? I mean, I know there's more crap that would be under both of those, but that's pretty much the basic, right?
Link to comment
Share on other sites

Yeah, that's the basic idea. You can store whatever text you want in the text field, if you want to have HTML that's fine.
Good deal!And then same goes for editing the content in a text area, correct? I can recall the information for the textarea tag and just have what is stored in the table be the original textarea content, then when I export it, I can just update the table, right? =]I think I'm beginning to understand all this MySQL junk and PHP stuff. It's so much easier when you actually have a teacher. ¬_¬
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...