July 21st, 2008
Tutorial : Creating a Content Management System using PHP/MySQL
editarticle.php
<?php
require_once("functions.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EDIT</title>
</head>
<body>
<?php
$id=$_GET['id'];
//checks whether $id is active i.e whether article.php?id= some value or not
if(isset($id)) {
$info = getArticle($id);
foreach($info as $key) {
?>
<form id="form" name="form" action="articlefunctions.php?a=edit&amp;amp;id=<?php echo $id ?>" method="post">
Article Title:<br />
<input name="title" type="text" id="title" value="<?php echo $key["articleTitle"]; ?>" /><br /><br />
Article Content:<br />
<textarea name="content" id="content"><?php echo $key["articleContent"]; ?></textarea>
<br /><br />
<input type="submit" value="Go" id="submit" name="submit"/>
</form>
<?php
}
}
?>
</body>
</html>
July 23, 2010 at 4:59 pm
whats happened to the code for function.php?
surely thats not it all?
i cant check in the source files either as they have gone.
its a shame, this looked like a good tutorial too.
June 30, 2010 at 12:30 pm
On page three the code is unintelligible http://visionmasterdesigns.com/tutorial-creating-...
please look after it.
June 16, 2010 at 7:13 am
To learn php,html,javascript,ajax,mysql,jquery with advanced concepts, you can visit <a href ="http://advancedphptutorial.blogspot.com">
Robin Leathal
-
Daniel S
-
parking games
-
Lucas Oger
-
Md. Sha alom
-
kaise
-
Skodeng
-
Skodeng
-
kaise
-
Skodeng
-
mightygame
-
Mike
-
Yen
-
I Really Need Help
-
Ken Bird
-
Michael
-
Brad
-
Brad
-
Ken Bird
-
Brad
-
Brad
-
Marc
-
Dave
-
Brad
-
Mike
-
Philips Tel
-
Michael
-
Ken Bird
-
Brad
-
Thank You!
-
Carlos
-
PHP Expert
-
ziya
-
shreeni
-
M1nn0w
-
M1nn0w
-
logicoflife90
-
Dan
-
kenyanprogrammer
-
jmac
-
Jon
-
Michael
-
Nico
-
AndrewPoison
-
AndrewPoison
-
Nico
-
AndrewPoison
-
Michael
-
AndrewPoison
-
Stefan
-
Michael
-
mightygame
-
Marc
June 12, 2010 at 5:28 pm
Definately there are lots of errors and missing codes. This php MySql tutorial can only be used to gather basic idea on creating a PHP MYSQL based Content Management Software. It should not be used for creating a productive website. You still need to make your CMS more secure.
June 11, 2010 at 10:54 pm
Hello.
Good job on this tutorial, but please – please – do not release such guides without major warnings. A user may be using this exact code, and soon he'll find that his DB is dumped and deleted. This has no protection what so ever, while that may not be the purpose of this guide, I'd suggest you to add a major warning at the beginning, because there will always be lazy peoples that will just C&P your code.
User entered data should always be checked, validated and eventually stripped. Never trust a user.
Regards,
Daniel S
June 10, 2010 at 7:07 pm
Hey how are you. I found your blog through Google and I just wanted to say that I think your writing is simply stunning! Thanks again for providing this content for free.
BR
June 7, 2010 at 4:33 pm
I am having problem with the first link. It gives a 404 error?
Thanks
May 19, 2010 at 4:58 am
Hey your tutorial about php and mysql to complete a content management site is very excellent. I hope the full content management system project as tutorial. it will be very well if u can every part as as a function as like as functions.php then it will be more helpfull for all
December 29, 2009 at 3:39 pm
Theres no database structure for this tutorial. Can anybody provide a it please.
Does anybody have an updated version for this with complete layout that gives you the ability to make pages visible or hide without deleteing pages/articles. also allow you to move the position up and down.
December 28, 2009 at 6:55 am
In some cases, phpadmin does not have password for "root". In that case, its suffice to omit 'admin' from function.php line 5 and do away without password, so your script should look like this :
function connect() {$conn = mysql_connect('localhost', 'root');
If not, you'll receive connecting error.
December 27, 2009 at 2:52 pm
bro, i can't access or view the demo file. Please tell me what am i suppose to do to get it right. Cheers for now.
November 10, 2009 at 7:39 am
Hello,
i'm a newbie and found this very nice but I feel it's not one for the newbies, this is designed at programmers who have experience of writing php and mysql, who don't really need the tutorial as they hav experience of it already.
What I feel it lacks is their is no use of CSS or any explanation of how to incorpotare CSS into the design, how would anyone upload pictures and place them where needed?
How to make content bold, centered, left or right. or use any other features.
I would be very grateful if you have a working CSS based CMS example that you can forward to me at kaise@hotmail.co.uk.
Kind Regards
kaise
December 28, 2009 at 7:00 am
Kaise, you can have your css file created separately and call it in your "article.php" file. Its just like how your set layouts in html, same rules apply. its common sense, mate.
October 29, 2009 at 9:34 am
I get this error:
Warning: Cannot modify header information – headers already sent by (output started at /home/——/public_html/main/articlefunctions.php:12) in /home/——-/public_html/main/articlefunctions.php on line 44
y?
October 19, 2009 at 1:57 pm
Hi any one knows how to add a subpage on each page created? If someone knows please help me. Need it asap.
September 6, 2009 at 9:32 am
Nice Tutorial. So much thanks for you.It’s simple to understand !
May I ask,how can I create a PHP that can upload image in the article? Would you have the related tutorial?
I search thousand of these kind of tutorial..and I only can get a successful start in your post.Thank you so much!
July 17, 2009 at 7:08 pm
Hi i really need help i have a project and its due next week, If a article does not exist how can i make an error saying this page does not exsit e.g. article.php?id=55 (ID:55 does not exsist) and it deisplays “This article could not be found” how can i do that??
This is due next week please help!!!
July 18, 2009 at 4:33 am
Do you have access to your mysql database? In there you will see the article table and the ID number that should apply to the heading of the article you are working on. Place that ID number in the php code of the page that contains the article.
July 17, 2009 at 2:14 am
How can i add an error if “?id=” nothing all i get is an empty page
Help Me!
August 21, 2009 at 6:49 pm
You can write an if statement to target the setting for 1 and if it doesn’t exist. If the if statement returns true, then you have one file in the system and it displays. If it is false, then, you simply echo a statement of ” There are no current articles “.
Here is a very simple example:
if (!’id’== 1 ) {
echo ” There is no current…” ;
}
else (‘id’== 1) {
return ‘id’;
}
August 21, 2009 at 6:56 pm
Quick note, the setup I gave you there was going from the id of the article itself, not the user id that can be easily confused by the way I wrote that.
Create your variable and value to reflect the article and don’t expose your actual ” ID ” to the public return that this example calls on.
Example variable and value to use:
$article_id = ‘ article_id ‘ ;
Use that and replace the ‘ id ‘ with ‘ article_id ‘ for using this example. I would hate to have my first post trash a bunch of novice code by having them give up the ghost…heh. Just FYI- change the id labels.
August 23, 2009 at 10:42 am
Brad – thanks for the information. Are you suggesting that the tables in the database be amended from ID to article_id? Another matter – do you have a script that will allow for an image to be loaded to a html page from a mysql database. I am looking to update the html page with article information as well as an image.
August 25, 2009 at 9:31 pm
Hey Ken,
Yeah, for my example only though…replace the ‘ id in the example to ‘ article_id ‘ to protect your files and not cross it with a user_id, which is normally referenced by the standard ‘ id ‘ label.
As for the second part, here is a really good reference tutorial on how to do just what you are looking for. It is primarily uploading images to a db but, it tells you how to display them back as well.
If you need anymore help with it, let me know and I’ll do my best to see what we can do about it.
August 25, 2009 at 9:32 pm
Here’s the tutorial link:
http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx
July 10, 2009 at 7:40 am
Sorry, JS gets slashed on here. You know what I meant.
June 24, 2009 at 1:20 am
Hello, Thanks for the tut but i managed to create sub pages aswell but the only problem is i want it to look like this
index.php?p=Home&subpage=Hi
but it looks like this index.php?p=Home then to view sub page you go on sub.php?subpage=Hi, Do you have any files on sub pages (ive just added sub pages e.g. colum = Sub = Home).
Thank You
August 21, 2009 at 7:25 pm
I ‘ think ‘ I understand what yo uare asking here…Try handling your subpages by checking out the articlefunctions.php of this article series and refubish the connection code to replace the current $action variable with $subpages, remove the sql processing and use the header location to point your proper pages for display. It will work the same way for what you are wanting to do. Also, look into ‘ object-oriented programming ‘ for more detailed methods on achieving this same result in a LOT better fashion.
October 19, 2009 at 2:49 pm
Hi dave can you teach me how to add subpage? i need your help. Thanks a lot.
May 29, 2009 at 11:02 am
great tutorial for beginner, but when i visit the page demo i got some error when insering data. like this
Warning: Cannot modify header information – headers already sent by (output started at /home/visionma/public_html/demo/cms/articlefunctions.php:12) in /home/visionma/public_html/demo/cms/articlefunctions.php on line 32
if im not wrong, perhaps you place the header(“Location:page.php”); after your html page, or in switch control logic…:-(, your page tutorial also get and error when request it, may be something wrong in your server. I think u need to repaired it,
it is very awesome!….i just take the script..
but…you have done the good stuff
thank you
May 31, 2009 at 12:37 am
Thanks a lot for noticing the error. I`ll definately work a fix on it
June 26, 2009 at 11:26 am
I am still getting this message after I add a new article title – Warning: Cannot modify header information – headers already sent by (output started at /home/ricniven/public_html/kenbirddesigns/bowlingclub/cms/articlefunctions.php:12) in /home/ricniven/public_html/kenbirddesigns/bowlingclub/cms/articlefunctions.php on line 32.
August 25, 2009 at 9:38 pm
Ken, it is probably clashing headers. Try putting ‘ exit( ) ; ‘ after the ‘ header(“Location: article.php”); ‘ lines to break that up. It’s recycling because a header function doesn’t ‘ disolve ‘ or time out without an exit function to kill it.
May 27, 2009 at 1:14 am
THANK YOU!!!!
I needed this script!
May 25, 2009 at 11:58 pm
Cara, onde tá o começo do script?? oras, como podem estar elogiando. O script não tem nem começo. A página deve estar interpretando o código oras. Vamos fazer um coisa bonita vai gente. Vamos fazer algo legal. A intenção é ótima, mas, se não pode ser utilizada, do que adianta.
Valeu.
Desculpe a sinceridade.
Carlos.
May 23, 2009 at 2:36 pm
Very good tuto !
____________________
Saguenay-IT, (IT Outsourcing, SOA, PHP, ASP, Flex, ActionScript, JavaScript…)
April 26, 2009 at 5:02 pm
nice article
April 16, 2009 at 10:35 pm
hey,
i am new starter well, i am trying out the tutorial .plz help out with following error
PHP Parse error: parse error in C:\Server\www\myserver.dev\public_html\functions.php on line 11
February 5, 2009 at 9:14 am
found the source code and so my question is moot. Thanks anyway. Still having a problem getting it to work but I’m working on it.
February 4, 2009 at 7:29 am
in this tutorial I think I am missing part of the code. I see the end of php statement but not the start. Here is what I get on the website:
‘.$row['articleTitle'].’ – EDIT – DELETE’;
}
}
closeconnection($conn);
}
function getArticle($id) {
$conn = connect();
$sql = “SELECT * FROM article WHERE id=’$id’”;
$result = mysql_query($sql);
if($result) {
$row = mysql_fetch_assoc($result);
$articleinfo[] = $row;
}
return $articleinfo;
closeconnection($conn);
}
?>
Is this correct? Am I missing something? Any help? Thanks
June 26, 2009 at 12:53 am
i have the same problem here. but there is some code missing.
it is the part how to connect to the db table.
January 27, 2009 at 1:12 am
Hey,
This comment is simply to help anyone who directly used the source code.
You will recieve a PHP Notice stating that the ID is not defined, when the article.php page is loaded. To ignore this Notice and remove it from displaying in your browser, simply place an @ sign at the problem line.
It should look like this:
@$id=$_GET['id'];
This will remove the Notice so your page displays as intended.
I hope this helps.
Regards,
Dan
November 16, 2008 at 7:29 pm
Michael,
I dont see a reply to AndrewPoison’s question…. It’s this article. You have seven pages in this article. How do you do that without a plugin, then?
COuld you please help us on that? I would like to use the same without any plugin. Just pure php code.
October 7, 2008 at 9:01 pm
I get a 404 error when I try to run the demo on my machine. All of the code is in “public_html” and I even created a sub folder called “cms” and download the code from the site there and I still get Http (404). Any ideas?
September 17, 2008 at 1:59 am
I’m having the same problem as Nico. Turning on error reporting gives me:
Notice: Undefined index: id in C:\server\www\myserver.dev\public_html\admin\articlefunctions.php on line 15
Any thoughts would be greatly appreciated!
August 16, 2008 at 9:00 pm
glad the problem is solved. Thanks AndrewPoison
August 15, 2008 at 11:46 pm
Hi Andrew
Thanks for the reply. I just checked the Go button “action statement” and it is correct. In my message above I was talking about the “url” shown in the “address bar” in the browser. I have kept the directory stucture the same.
umm… I think that the bug is in the communication between the php and the mySQL database. If that helps in any way.
August 15, 2008 at 9:57 pm
/edit: if you did, try a single point or even no point at all (“./articlefunctions.php?a=add” or “/articlefunctions.php?a=add”) instead.
August 15, 2008 at 9:55 pm
@Nico: isnt it supposed to be
action=”articlefunctions.php?a=add”
and not
action=”../articlefunctions.php?a=add” ? Or did you change the directory structure?
August 15, 2008 at 9:14 pm
Hi Michael!
This is my first attempt at PHP and MySQL so please bear with me.
OK so it all works, until I fill in the details (../insertarticle.php) try to click the button “Go”. Then I get a blank white screen and the link is pointing to ../articlefunctions.php?a=add.
I guess I am doing something wrong here and I guess “Help Please!” is the next question
August 13, 2008 at 10:03 pm
It’s this article. You have seven pages in this article. How do you do that without a plugin, then?
I am using WP 2.6 and don’t see any way how to get this working :/
Btw: would it be okay for you if I translate some of your articles into german and post them on my site (with a link back to you, of course)? I found them to be quiet usefull and would like to present them another audience.
August 13, 2008 at 7:43 pm
Hello Andrew,
I haven`t used any plugin to have multiple pages in an article. Which page are you talking about ?
August 12, 2008 at 7:01 pm
Hey there, Michael,
what’s the name of the plugin you used to have multiple pages in one single article?
August 1, 2008 at 12:47 pm
Hi Michael,
If this is only a warning…. How do we go about to give you rather an example of what the article looks like after its been updated or edited..
July 26, 2008 at 1:58 pm
hey mightygame,
its not an error, just a warning,
header() function is used when you want to redirect to a particular page or tell the browser what content your page is of.
Don`t worry, its not an error as long as the system is working.
Regards
July 26, 2008 at 6:10 am
I get this error:
Warning: Cannot modify header information – headers already sent by (output started at /home/——/public_html/main/articlefunctions.php:12) in /home/——-/public_html/main/articlefunctions.php on line 44
y?
July 10, 2009 at 7:39 am
Replace the header(); function with this:
echo “window.location = ‘article.php’;”;