General Statistics
390 Tutorials
202 Total Votes
10 User(s) Online
975113 Views Total
3000 Registered Members
24734 Posts Total
Rooneyfeld is our newest member
About this Tutorial: Advanced Tutorial CMS Script v1
Advanced Tutorial CMS Script v1
Rated 5 / 4 Votes

Advanced Tutorial CMS Script v1

The ultimate tutorial content management system. With built in self installer and administration panel, its your all in one package!


Date Added: November 21, 2005 [ 34500 Views - 4 Votes ] [ Rate ]

Author: Chaos King [ PHP Coding ] [ 27 Comment(s) ]

Advanced Tutorial CMS Script v1
Note: Check out Tutorial CMS (www.tutcms.com) for updates on the new script!

5) Finally, the last file to add; admin.php. Place this code in there:

CODE

<?php

//Getting the file db.php which includes our database settings. 
define( 'DB_PATH'  , "../" );
require DB_PATH."db.php";

// Setting up some variables
$request_id = $_REQUEST['id'];

// Page: admin.php?act=addnew
if ($act == addnew) {
echo "
<form name='form' method='post' action='admin.php?act=addnew'>
  <table width='80%' border='0' cellspacing='3' cellpadding='0'>
  <tr>
    <td width='20%'>Name:</td>
    <td width='79%'>
<input name='name' type='text' id='name' size='40'></td>
  </tr>
  <tr>
<td>Avatar:</td>
<td>
<input name='avatar' type='text' id='avatar' value='http//' size='40'></td>
  </tr>
  <tr>
<td>Category:</td>
    <td>
<input name='category' type='text' id='category'
value='Automatically makes new category' size='40'>
        </td>
  </tr>
  <tr>
<td>Description:</td>
<td>
<input name='description' type='text' id='description' size='40'></td>
  </tr>
  <tr>
<td>Author:</td>
<td>
<input name='author' type='text' id='author' size='40'></td>
  </tr>
  <tr>
<td>Email:</td>
<td>
<input name='email' type='text' id='email' size='40'></td>
  </tr>
  <tr>
<td>Content</td>
<td>
<textarea name='content' cols='65' rows='10'></textarea></td>
  </tr>
  <tr>
<td><input name='submit' type='submit' id='submit' value='Submit'>
    <input name='reset' type='reset' id='reset' value='Reset'></td>
<td>If you mess up, a edit link will be available on submit. </td>
  </tr>
  </table>
</form>";

  if ($_POST['submit']) {

  $name = $_POST['name'];
  $avatar = $_POST['avatar'];
  $category = $_POST['category'];
  $description = $_POST['description'];
  $author = $_POST['author'];
  $email = $_POST['email'];
  $content = $_POST['content'];
  $date = date('m-d-Y');

    if (!$name || !$avatar || !$category ||
!$description || !$author || !$email || !$content) {
    die ('Sorry, a field was left blank.  Check all fields again!');
    }
    else {
    mysql_query("INSERT INTO & #036;mysql_table(id, title, avatar, date, category,
description, author, email, content, views)
VALUES('', '$name', '$avatar', '$date', '$category', '$description',
'$author', '$email', '$content', '' ) " )
or die('Sorry, it failed');
    echo "Success!  You have added the tutorial
<strong>$name</strong> to the category
<strong>$category.</strong><br>What would you like to do?<br>
<a href='?act=addnew'>Add  a new tutorial</a> &nbsp; ----&nbsp;
<a href='?act=view'>Edit / Delete a previous tutorial</a>";
    }
  }
}


// Page: admin.php?act=edit&id=##
if ($act == edit && $id == $request_id) {
$result = mysql_query("SELECT * FROM $mysql_table
WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){
  echo "
  <form name='form' method='post''>
    <table width='80%' border='0' cellspacing='3' cellpadding='0'>
<tr>
      <td width='20%'>Name:</td>
      <td width='79%'>
<input name='name' type='text' id='name'

] value='".$row['title']."' size='40'></td>
 </tr>
<tr>
<td>Avatar:</td>
<td><input name='avatar' type='text' id='avatar'
value='".$row['avatar']."' size='40'></td>
    </tr>
<tr>
<td>Category:</td>
  <td>
<input name='category' type='text' id='category'
value='".$row['category']."' size='40'>        </td>
    </tr>
<tr>
<td>Description:</td>
  <td>
<input name='description' type='text' id='description'
value='".$row['description']."' size='40'></td>
    </tr>
<tr>
<td>Author:</td>
<td><input name='author' type='text' id='author'
value='".$row['author']."' size='40'></td>
    </tr>
<tr>
<td>Email:</td>
<td><input name='email' type='text' id='email'
value='".$row['email']."' size='40'></td>
    </tr>
<tr>
<td>Content</td>
<td><textarea name='content' cols='65' rows='10'>
".$row['content']."</textarea></td>
    </tr>
<tr>
<td><input name='submit' type='submit' id='submit' value='Edit'></td>
<td></td>
    </tr>
    </table>
  </form>
  ";
 
  if ($_POST['submit']) {

  $name = $_POST['name'];
  $avatar = $_POST['avatar'];
  $category = $_POST['category'];
  $description = $_POST['description'];
  $author = $_POST['author'];
  $email = $_POST['email'];
  $content = $_POST['content'];
   
    mysql_query("UPDATE $mysql_table SET title='$name', avatar='$avatar',
category='$category', description='$description', author='$author',
email='$email', content='$content' WHERE id='$request_id'") or die('Sorry, it failed');
    echo "Success!  Your tutorial has been edited.<br>
What would you like to do?<br><a href='?act=addnew'>
Add  a new tutorial</a> &nbsp; ----&nbsp; <a href='?act=view'>
Edit / Delete a previous tutorial</a>";
  }
}
}

// Page: admin.php?act=delete&id=##
if ($act == delete && $id == $request_id) {
$result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){

  echo "
  <form action='?act=delete&id=".$row['id']."' method='post' name='form1'>
    Are you sure you want to delete the tutorial: <strong>".$row['title']."<strong>?
    <br>
    <input name='yes' type='checkbox' id='yes' value='checkbox'>
    Yes<br>
    <input name='no' type='checkbox' id='no' value='checkbox'>
    No
    <br>
    <input name='submit' type='submit' id='submit' value='Submit'>
  </form>";
}
 
if ($_POST['submit']){

  if ($_POST['yes'] && $_POST['no']){
  die('Error! : Are you trying to confuse me?');
  }

  if ($_POST['yes']){
 
  $result = mysql_query("SELECT * FROM $mysql_table WHERE id='$request_id'");
  while($row = mysql_fetch_array($result)){
   
    mysql_query("DELETE FROM $mysql_table WHERE id='$request_id'");   
    echo "
    Thanks, the tutorial <strong>".$row['title'].".</strong> has been deleted.
<a href='?'>Click here</a> to continue.
    ";
  }
  }

  if ($_POST['no']){
  die('<a href="?">Click here</a> to continue.');
  }
 
  if (!$_POST['yes'] && !$_POST['no']){
  die('Oops, you forgot to respond to my question.');
  }
   
 

}



// Page: admin.php?act=view
if ($act == view) {
echo "
<table width='700' border='0' cellspacing='0' cellpadding='0'>
  <tr>
  <td><strong>ID</strong></td>
  <td><strong>Name</strong></td>
  <td><strong>Author</strong></td>
  <td><strong>Category</strong></td>
  <td><strong>Edit / Delete</strong></td>
  </tr>
  ";
  $result = mysql_query("SELECT * FROM $mysql_table ORDER BY ID ASC");
  while($row = mysql_fetch_array($result)){
  echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['title']."</td>
<td><a href='mailto:".$row['email']."'>".$row['author']."</a></td>
<td>".$row['category']."</td>
<td><a href='admin.php?act=edit&id=".$row['id']."'>Edit</a> /
<a href='admin.php?act=delete&id=".$row['id']."'>Delete</a></td>
    </tr>
  ";
  }
echo "</table>";
}

// Page: admin.php
if (!$act) {
echo "
What would you like to do?<br><a href='?act=addnew'>
Add a new tutorial</a> &nbsp; ----&nbsp;
<a href='?act=view'>Edit / Delete a previous tutorial </a>
";
}
?>


6) Note: Check out Tutorial CMS (www.tutcms.com) for updates on the new script!

And lastly, run the install.php via www.domain.com/install.php and if you get no errors, refresh the page and that file should not be there anymore. Go to your admin panel and start adding tutorials!

Please Stay Tuned for v2 of the script. Including more features, for more people. :)


Total Pages (5)
<<Prev 1 2 3 4 [5] 

Welcome User
Welcome Guest
( Login | Register )

Latest Tutorial Index - RSS Feed
Latest Resources - RSS Feed
Latest Tutorials - RSS Feed
Vote for Us
  • VixxIMG.com - Free Image Hosting, Free Myspace Image Hosting, Free Image Uploads
  • PageRank Plus - Google PageRank checking, with a twist.
Random Affilaites