17
Content Management System (CMS) Lecturer: Owen Funnell

Web server scripting 1

Embed Size (px)

DESCRIPTION

Web

Citation preview

Page 1: Web server scripting 1

Content Management System (CMS)

Lecturer: Owen Funnell

Page 2: Web server scripting 1

This Lesson….

• What is CRUD• What is a CMS• Building a CMS

Lecturer: Owen Funnell

Page 3: Web server scripting 1

What is a CMS?“A content management system, or CMS, is a web

application designed to make it easy for non-technical users to add, edit and manage a website.”

http://en.wikipedia.org/wiki/Content_management_system

Lecturer: Owen Funnell

Page 4: Web server scripting 1

Front End and Back EndWebsite Front Ends

Lecturer: Owen Funnell

Page 5: Web server scripting 1

Front End and Back EndWebsite Back Ends

Lecturer: Owen Funnell

Page 6: Web server scripting 1

C.R.U.D

Lecturer: Owen Funnell

Operation SQL

Create INSERT

Read (Retrieve) SELECT

Update (Modify) UPDATE

Delete (Destroy) DELETE

We use SQL queries in PHP to perform certain operations inside databases

Page 7: Web server scripting 1

Install a Blog

Lecturer: Owen Funnell

Page 8: Web server scripting 1

Install a Blog

Lecturer: Owen Funnell

DO NOT install into the root of your public_html

http://www.YOURDOMAIN.co.uk/myblog/

Page 9: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/Creating the tables for our database and adding example data

Page 10: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/Copy the SQL query, paste it into the SQL query terminal and press go

Page 11: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/

What is a Include/require statement?include takes a file name and simply inserts that file's contents into the script that

issued the include command.

<html><body>

<h1>Welcome to my home page!</h1><p>Some text.</p><p>Some more text.</p><?php include 'footer.php';?>

</body></html>

require("db.php");

Page 12: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

What is a Include/require statement?

Page 13: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/

CRUD - Create

<?phpif (isset($_POST['submit']))

{ include 'db.php';

$title=$_POST['title'] ;$author= $_POST['author'] ;$name=$_POST['name'] ;$copy=$_POST['copy'] ;mysql_query("INSERT INTO `books`(Title,Author,PublisherName,CopyrightYear) VALUES ('$title','$author','$name','$copy')");

}?>

Page 14: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/

CRUD - Read <?phpinclude("db.php");$result=mysql_query("SELECT * FROM books");

while($test = mysql_fetch_array($result)){$id = $test['BookID'];echo "<tr align='center'>";echo"<td><font color='black'>" .$test['BookID']."</font></td>";echo"<td><font color='black'>" .$test['Title']."</font></td>";echo"<td><font color='black'>". $test['Author']. "</font></td>";echo"<td><font color='black'>". $test['PublisherName']. "</font></td>";echo"<td><font color='black'>". $test['CopyrightYear']. "</font></td>";echo"<td> <a href ='view.php?BookID=$id'>Edit</a>";echo"<td> <a href ='del.php?BookID=$id'><center>Delete</center></a>";

echo "</tr>";}

mysql_close($conn);?>

Page 15: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/

CRUD - Update if(isset($_POST['save'])){

$title_save = $_POST['title'];$author_save = $_POST['author'];$name_save = $_POST['name'];$copy_save = $_POST['copy'];

mysql_query("UPDATE books SET Title ='$title_save', Author ='$author_save', PublisherName ='$name_save',CopyrightYear ='$copy_save' WHERE BookID

= '$id'") or die(mysql_error()); echo "Saved!";

header("Location: index.php");}

Page 16: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/

CRUD - Delete <?php include("db.php");

$id =$_REQUEST['BookID'];

// sending querymysql_query("DELETE FROM books WHERE BookID = '$id'")or die(mysql_error());

header("Location: index.php");?>

Page 17: Web server scripting 1

Simple CMS

Lecturer: Owen Funnell

http://www.owenfunnell.co.uk/build-a-simple-cms/

Create your Simple Content Management System

Finnish all of your Basic PHP tutorials