Web server scripting 1
-
Upload
owen-funnell -
Category
Technology
-
view
368 -
download
0
description
Transcript of Web server scripting 1
Content Management System (CMS)
Lecturer: Owen Funnell
This Lesson….
• What is CRUD• What is a CMS• Building a CMS
Lecturer: Owen Funnell
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
Front End and Back EndWebsite Front Ends
Lecturer: Owen Funnell
Front End and Back EndWebsite Back Ends
Lecturer: Owen Funnell
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
Install a Blog
Lecturer: Owen Funnell
Install a Blog
Lecturer: Owen Funnell
DO NOT install into the root of your public_html
http://www.YOURDOMAIN.co.uk/myblog/
Simple CMS
Lecturer: Owen Funnell
http://www.owenfunnell.co.uk/build-a-simple-cms/Creating the tables for our database and adding example data
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
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");
Simple CMS
Lecturer: Owen Funnell
What is a Include/require statement?
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')");
}?>
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);?>
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");}
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");?>
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