← Kirby Week 2008: The Core

Kirby Week 2008: Administering Stuff

On the second day of Kirby Week, Four Island gave to me: A tutorial on coding an admin panel.

Welcome back to the second day of Kirby Week! As I told you yesterday, today's post is about writing an Admin Panel! Yay! We're going to only create a very basic panel: Single user login and when you get there, all you can do is write posts.

We'll be storing the single user in the database for some deranged reason. Possibly later we'll add multi-user support, I don't know. Anyway, here's the schema for the users table:

CREATE TABLE `users` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 255 ) NOT NULL DEFAULT ''
);

And remember to add a user to the users table!

First, you need a login form. I'll let you handle this as, I assume, if you're writing a blog you probably know something or other about HTML. It should POST to admin.php and contain Username (NAME="username") and Password (NAME="password") fields.

Finish the form? Good. Now, we need to write the back end. Create a file called admin.php and put this in it: http://other.fourisland.com/kirbyweek08/?source=admin.php.

Since I don't want to do all of the work, I'm going to let you design another form! YAY. Between the two comments ([/code]), create a form thatPOSTs toadmin.php?submit=. Create a textbox in itNAMEdtitle, a textareaNAMEdtextand another textboxNAMEdtags`. Obviously, also put in a submit button.

You may want to label the elements so you know what to do while posting. The first is the Title of the post, the second is the content, and the third is the comma-delimited list of tags for the post.

YAYish, I guess. We're done with the Admin panel.... Sort of. The admin panel is currently annoying, you have to type in all of your formatting and such using HTML. We'll fix that with a handy JavaScript editor called TinyMCE.

Download TinyMCE from the aforementioned link, extract it and plop the jscripts/tiny_mce folder into your kirbyweek08 folder. Now, let's add TinyMCE to our admin panel. Append this code above your FORM.

Hurray! If everything went right, your admin panel should now be better looking and easier to use! Remember that this is just a basic model and you should really style it and add more functionality on your own.

Next time, we'll be adding commenting system to your blog so people have the chance to talk about the wonderful things you're blogging about.), create a form thatPOSTs toadmin.php?submit=. Create a textbox in itNAMEdtitle, a textareaNAMEdtextand another textboxNAMEdtags`. Obviously, also put in a submit button.

You may want to label the elements so you know what to do while posting. The first is the Title of the post, the second is the content, and the third is the comma-delimited list of tags for the post.

YAYish, I guess. We're done with the Admin panel.... Sort of. The admin panel is currently annoying, you have to type in all of your formatting and such using HTML. We'll fix that with a handy JavaScript editor called TinyMCE.

Download TinyMCE from the aforementioned link, extract it and plop the jscripts/tiny_mce folder into your kirbyweek08 folder. Now, let's add TinyMCE to our admin panel. Append this code above your FORM.

Hurray! If everything went right, your admin panel should now be better looking and easier to use! Remember that this is just a basic model and you should really style it and add more functionality on your own.

Next time, we'll be adding commenting system to your blog so people have the chance to talk about the wonderful things you're blogging about.

Hatkirby on December 15th, 2008 at 12:31:54pm
👍 3 👎

Comments

Replying to comment by :
Feel free to post a comment! You may use Markdown.