Hey guys. I was wondering if it's possible to have a page say /admin.php, where I can create new pages from?
I want to be able to create new pages from another page on my site, like /admin.php
On that page, I'd have a form for the page's properties, like file name. Could anyone assist me in doing this?
I'm really new to php and want to get better.
What do you consider a "page" ... not sure what you mean by that.
Are you talking about creating a text file (for content)?
Usually, you don't create a "page", as in an HTML or PHP web page ...
you create the text or content for another script to use ... which generates
the HTML "page". Typically using a database, like MySQL.
Yes. Here I'll explain.
I'm trying to make a site so that I don't have to edit it by uploading files to ftp to make small changes like adding news or links. I'd also like to be able to create a new page.
Here below is what it would look like.
Code:
<html>
<body bgcolor=FFFFFF>
<a href="http://www.MYSITE.com/home.php">HOME</a> - <a href="http://www.MYSITE.com/news.php">NEWS</a> - <a href="http://www.MYSITE.com/coollinks.php">COOL LINKS</a> -
</br>
This is the homepage.
</body>
</html>
I want to have a page, where I can edit what it says in home.php in the part where it says "This is the homepage". The same thing goes for news.php and coollinks.php.
But I'd also want to be able to add a new page, but I'll do that later when I'm able to do this.
That is called a CMS (content management system).
Somehow, you either need to use a database (like MySQL),
or a simpler text (flat-file) database, or at a minimum, some plain text files.
Let's go with the most basic, plain text files ...
The first step is to create the text you want and save it in files.
You might want to do them in sections, like:
n1.txt, n2.txt, n3.txt for paragraphs of news,
and l1.txt,l2.txt,l3.txt for paragraphs (or content) for links.
Create those text files and put text in them (you can also put HTML in them).
Upload them all into a directory called "content".
Then, wherever you want them to appear, you do this:
<?php include("./content/n1.txt")?>
The PHP script will take the contents of "n1.txt" and display it at that spot.
Do that for all of your content.
The next step is to find a simple PHP editor to edit those text files,
or edit them using notepad and upload them. The PHP editor is something
you can do later, when you learn more about PHP.
But the PHP "includes" is the most basic, first step, to putting content on your page,
without using a database (like MySQL). Eventually, you'll be wanting to get more
elaborate and learn MySQL.
Database is more simple and more powerful for experienced people,
but in his case, he'll need to know MySQL and set-up
variables, and the coding to read and write the database.
The "point" is ... MySQL is simpler for an experienced programmer.
Wincode ...
How far are you planning on going with your site?
Adding dozens or hundreds of "content" paragraphs?
Searching, sorting, dating them, etc?
We can't teach you a whole programming class on this forum,
so I would say ... you have a start on it, where do you want
to go from here?
No I want it very simple.
I just want 4-5 pages, in which I can update regularly.. I want maybe one master paragraph for each page, where I can change and add to the paragraph (but possibly be able to add links (without coding), images, and file uploading, so in other words a veryy simple editor). But I guess those are complex, so at the moment I just want to be able to add/change text to the pages.
Thank you so much for your help!
I think I have an idea of how it would work..
What I would have is connect to the database and set up a 5 variables (each for a page paragraph). Then on the page where I edit my pages, I would have the editors. And what the editors would do is display what each variable has. Say one of the vairables is $page1, then I can view what's in it and change it/add to it.
Then on www.mysite.com/page1.php , I'd have an include statement to include the variable $page1.
But my problem is I don't know how to do it...
Below is the simplest online text editor ever ... no security, no frills ...
Make sure all of your text files have CHMOD permissions set to 0777 (or 777),
using your FTP program ... you can set those permissions, so you can write to them.
PHP Code:
<?php
// Give this script a name like, "edit.php"
// Very simple text editor.
// To edit one of your files, call it like this:
// <a href="edit.php?p=n1.txt">Edit n1.txt</a>
// There is no error checking, no security,
// just a plain text editor.
Also, on the edit.php?p=blahblah, there are two "Save Changes" buttons. In between them is this text ""; } function br2nl($str) { return preg_replace('=
=i', "", $str); } ?>"