Jump to content


CMS - First Time


16 replies to this topic

#1 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 02 May 2006 - 02:43 PM

Hey guys,

I have learnt quite a bit of PHP but have never created an actual script 100% by myself, I have modified scripts but how would I go about creating a Content Management System? I know how to connect to a MySQL Database and how to add a table but where do I go from there? Do I query the Database and if so for what and then to display it do I just use something like mysql_grab I am really confuddled.

I want the basic feautres for the CMS as I need to be more and more proficient in PHP so I would love to have a bit of input and direction to a few baselines of the following:

Displaying News

Admin Pane
- Add News
- Delete News
- Edit News

Thanks for your help,
Danl

#2 Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 02 May 2006 - 03:21 PM

http://kudosphp.com

That is my website, it is NOT done, however it is a CMS in devellopment. With whats there you should be able to get the hang of how its made.

In my CMS what i've done is attached each page I have to a number. Then when a user types in or is linked to that specific number the CMS loads the corresponding page. So I have a function that looks at the number then goes into the database and looks at what page it is. Then loads it in. For instance say 1 was News so my script would then say include('News.php');

Its quite simple. Then all you need are CMS functions, perhaps a forum or a Private Messaging system.

Hope this helps!

#3 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 02 May 2006 - 03:23 PM

a CMS can be quite hard to do, you have to take a lot into consideration, ease of use, security and so forth.

If your quite new with php i would try and make parts of it bit by bit, so a news script firs lets say.

Try looking over some tutorials in the db at news scripts then go about making your own and getting used to how it all works.

#4 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 02 May 2006 - 04:05 PM

View Postdeadly, on May 2 2006, 09:23 PM, said:

a CMS can be quite hard to do, you have to take a lot into consideration, ease of use, security and so forth.

If your quite new with php i would try and make parts of it bit by bit, so a news script firs lets say.

Try looking over some tutorials in the db at news scripts then go about making your own and getting used to how it all works.

Thats what I have done so far, I heavily edited Project Rages but never seemed to get it how I wanted it.

#5 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 02 May 2006 - 06:20 PM

I need quite a bit of help now. I have created the basic admin panel but I am stuck on how to display the contents that has been posted into my MySQL Database, I want to know if I would use something like this:

$query1 = "SELECT * FROM news WHERE ID'$id';

$result = mysql_query($query) or die(mysql_error());

Or am I just chasing a whole different thing?

#6 BigDog

    Young Padawan

  • Members
  • Pip
  • 277 posts
  • Gender:Male
  • Location:Orange County, California
  • Interests:Running, building computers, PC games and BMX and programming.

Posted 02 May 2006 - 07:52 PM

Ok, I can help you with that! :)

$result = mysql_query("SELECT * FROM news WHERE ID'$id');
while($row = mysql_fetch_array($result)){
  echo "
<textarea name='tutorial' cols='96' rows='20' id='tutorial'>".$row['content']."</textarea>
";

So lets look at the above code

$result = mysql_query("SELECT * FROM news WHERE ID='$id');
Thats our result! Its what we tell it to get from the sql table called News!

now while $row=$result! it should mean anything under .$row['XXXX'].
will be getting out of the news table!
So if you have author row under the news table, you can do this

<input name="author" size="20" value=".$row['author']."> And that will echo anything under the author row!

I dont know if that helped at all, but just keep looking at tutorials!

#7 mbx5nitro

    Young Padawan

  • Members
  • Pip
  • 113 posts
  • Gender:Male
  • Location:Houston, TX

Posted 02 May 2006 - 07:59 PM

Change: $query1 = "SELECT * FROM news WHERE ID'$id';
To: $query1 = "SELECT * FROM news WHERE (ID='$id')";

On my site http://www.mtbzu.com
I used ColdFusion but PHP will do the samething. I have it so my index calls my news from my news table.
All my pages at the top all the info is pulled out of a database and sent into a table area for it all. The comments area uses a database too and does the samething. Although the complecated area of the site was the link "Mountain Biking" That page is made via a script. In my admin panel i can type info in and type a url for a image and other things, then it is all stored in a table with a page name. Then my menu script pulls all the activated pages out of the database and creates a link to those pages.


This could all be done with PHP although i used ColdFusion because my host had it and Dreamweaver makes it so easy.

#8 Indigo

    Official Alien

  • Members
  • PipPipPip
  • 617 posts
  • Gender:Male
  • Location:Trondheim, Norway
  • Interests:Computing in general, especially design and programming of all kinds.

Posted 03 May 2006 - 01:55 AM

Personally, Iīve build my CMS from the ground with functions, I have a function for adding news, one for editing, etc. In that way, I donīt have to use 40 files, but build 4-5 files into one instead. I feel this really help me, as I only have to make one file work instead of 4-5.

When I make stuff it really helps me making things my own way, not the way all the other CMS (as you see in tutorials are build), but these do really help in the beginning process.
Please try a tutorial-search, there should be enough tutorials on how to build both basic CMS and news-administration systems.

#9 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 03 May 2006 - 01:58 PM

View PostDanWilliamson, on May 2 2006, 11:05 PM, said:

Thats what I have done so far, I heavily edited Project Rages but never seemed to get it how I wanted it.

Did you really? I wrote that CMS :P

#10 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 03 May 2006 - 03:10 PM

View PostWybe, on May 3 2006, 07:57 PM, said:

View PostDanWilliamson, on May 2 2006, 11:05 PM, said:

Thats what I have done so far, I heavily edited Project Rages but never seemed to get it how I wanted it.

Did you really? I wrote that CMS :P

*bows down unto thee*

#11 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 04 May 2006 - 03:30 AM

View PostDanWilliamson, on May 3 2006, 10:10 PM, said:

*bows down unto thee*

lol that you don't have to do, but if you have questions regarding it you now know who to ask :o

Edited by Wybe, 04 May 2006 - 03:31 AM.


#12 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 04 May 2006 - 03:45 AM

View PostWybe, on May 4 2006, 09:30 AM, said:

View PostDanWilliamson, on May 3 2006, 10:10 PM, said:

*bows down unto thee*

lol that you don't have to do, but if you have questions regarding it you now know who to ask :o

Yes, You have to correct one line otherwise you grt an error here is the correct code it's just a mispelling of the IF statement.

<? include('dbconnect.php'); ?> 
<form action="addnews.php" method="post"> 
<br>Title: 
<br><input name="title" type="text" value="Title"> 
<br>Author: 
<br><input name="user" type="text" value="Name"> 
<br>Date: 
<br><input name="date" type="text" value="<?php print date("F j Y"); ?>"> 
<br>Icon: 
<br><input name="icon" type="text" value="Icon URL"> 
<br>Message: 
<br><textarea name="message" cols="40" rows="6" value="Message"> </textarea> 
<br>Password: 
<br><input name="password" type="password"> 
<br><input name="submit" type="submit" value="Submit"> 
<?php $password="yourpassword"; //change this to the password you want if ($_POST['password']==$password){ //DO NOT CHANGE THIS LINE 
if (isset($_POST['submit'])) { 
include("dbconnect.php"); 
$title = addslashes(strip_tags($_POST['title'])); 
$user = addslashes(strip_tags($_POST['user'])); 
$icon = addslashes(strip_tags($_POST['icon'])); 
$message = $_POST['message']; 
$date = addslashes(strip_tags($_POST['date'])); 
$sql = "INSERT INTO newscms SET title='$title', user='$user', icon='$icon', message='$message', date='$date'"; 
if (mysql_query($sql)) { 
// this is the statement fixes
echo("Your news has been added."); 
} else { 
echo("Error adding entry: " . mysql_error() . ""); 
} 
} 
?>

Edited by DanWilliamson, 04 May 2006 - 03:46 AM.


#13 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 04 May 2006 - 04:20 AM

Sure, but what file is it and what line exactly? I haven't looked into that CMS (I think I called it "SiSy") for ages

#14 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 04 May 2006 - 07:45 AM

It is in addnews.php or add.php and it is line 27 if was just:

f (mysql_query($sql)) {

While it should be:

if (mysql_query($sql)) {
// this is the statement fixes


#15 Jem

    Young Padawan

  • Members
  • Pip
  • 93 posts
  • Location:England
  • Interests:Photography, design &amp; developing, walking, cycling, reading.

Posted 05 May 2006 - 06:19 AM

I recently wrote a blog entry on "Writing Your Own CMS". It won't help you with coding, because that's not the point of it, but it may give you a few ideas and things to consider whilst your developing your CMS:
http://www.jemjabella.co.uk/post.php?title...ng_your_own_cms

#16 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 07 May 2006 - 11:58 AM

Jem, that blog entry really sums up the stuff no other tutorials cover. Great link!

#17 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 07 May 2006 - 01:49 PM

Wow that article kicks ass, I have created a basic one, I have used .htaccess to block the administration panel but I think I will learn quite a bit more about PHP/MySQL until I make a new one.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users