Jump to content

Creating a Master Admin Page ??


spacepoet

Recommended Posts

Hello:

 

Seeking some input, please.

 

I use single-pages in my admin panel to update and maintain each corresponding page on the front end.

ADMIN = FRONT END
a_Home.php = Home.php
a_About.php = About.php
Etc...

 

The code is the same for each page, except I have to rename the TABLE everytime I make a new page:

<?php

include('../include/myConn.php'); //contains your mysql connection and table selection
include('../include/myCodeLib.php');
include('include/myCheckLogin.php');
include('include/myAdminNav.php');

include('ckfinder/ckfinder.php');
include('ckeditor/ckeditor.php');

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{

$myTitle = mysql_real_escape_string($_POST['myTitle']);
$myDesc = mysql_real_escape_string($_POST['myDesc']);
$myHeader = mysql_real_escape_string($_POST['myHeader']);
$mySubHeader = mysql_real_escape_string($_POST['mySubHeader']);
$myPageData = mysql_real_escape_string($_POST['myPageData']);

$sql = "
UPDATE myTestimonials
   SET
      myTitle = '$myTitle',
      myDesc = '$myDesc',
      myHeader = '$myHeader',
      mySubHeader = '$mySubHeader',
      myPageData = '$myPageData'
  ";
    
mysql_query($sql) && mysql_affected_rows()
    
?>

<script language="JavaScript">
alert("This page was updated!");
location.href = "a_Testimonials.php";
</script>

<?php
}


$query=mysql_query("SELECT * FROM myTestimonials") or die("Could not get data from db: ".mysql_error());
while($result=mysql_fetch_array($query))
{
  $myTitle=$result['myTitle'];
  $myDesc=$result['myDesc'];
  $myHeader=$result['myHeader'];
  $mySubHeader=$result['mySubHeader'];
  $myPageData=$result['myPageData'];
}
?>

<!DOCTYPE HTML>

<html>

<head>

<meta name="author" content="MontyTheWebmaster.com" />
<meta charset="ISO-8859-1" />

<title>Admin Area</title>

<?php echo spAdminLinks(); ?>

</head>

<body>

<div id="siteContainer">

<div id="topContainer">
	<?php echo spAdminTopMenu(); ?>
</div>

	<div id="topMenuContainer">
		<div id="topMenu">
			<?php echo spAdminMenu(); ?>
		</div>
	</div>

<div id="contentContainer">


	<div id="mainContent">

		<h1>Editing: Testimonials</h1>

		<p>

         <form method="post" action="<?php echo $PHP_SELF;?>">
         <input type="hidden" name="POSTBACK" value="EDIT">
         
         
         <div style="float: left; width: 120px; margin-right: 30px;">
         
         Page Title:
         
         </div>
         
         <div style="float: left; width: 550px;">
         
         <textarea cols="80" rows="1" name="myTitle"><?php echo $myTitle; ?></textarea>
         
         </div>

         <div style="clear: both;"><br /></div>
         

         <div style="float: left; width: 120px; margin-right: 30px;">
         
         Page Description:
         
         </div>
         
         <div style="float: left; width: 550px;">
         
         <textarea cols="80" rows="1" name="myDesc"><?php echo $myDesc; ?></textarea>
         
         </div>

         <div style="clear: both;"><br /></div>
         
         <div style="float: left; width: 120px; margin-right: 30px;">
         
         Page Header:
         
         </div>
         
         <div style="float: left; width: 550px;">
                 
         <textarea cols="80" rows="1" name="myHeader"><?php echo $myHeader; ?></textarea>
         
         </div>

         <div style="clear: both;"><br /></div>

         <div style="float: left; width: 120px; margin-right: 30px;">
         
         Page SubHeader:
         
         </div>
         
         <div style="float: left; width: 550px;">
                 
         <textarea cols="80" rows="1" name="mySubHeader"><?php echo $mySubHeader; ?></textarea>
         
         </div>

         <div style="clear: both;"><br /></div>
         
         Page Content:<br />         
         
         <textarea cols="80" id="myPageData" name="myPageData"><?php echo $myPageData; ?></textarea>




            <script type="text/javascript">
             
             CKEDITOR.replace( 'myPageData',
      			{
         			filebrowserBrowseUrl : 'ckfinder/ckfinder.html',
         			filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?Type=Images',
         			filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?Type=Flash',
         			filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
         			filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
         			filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
      			}
			);

            </script>




       
         <br />
         
         <input type="submit" value="Submit" />

         </form>

		</p>

	</div>

	<div style="clear: both;"></div>

</div>

<div id="footerContainer">

	<?php echo spAdminFooter(); ?>

</div>

</div>

</body>

</html>

 

What I am curious about is how can I take this page and make it so I can add a new page, delete a page, etc. all from just one page like above?

 

And on the frontend, what would be the best way to display the data in a search engine friendly way (i.e. without QueryStrings like MyPage.php?id=2

Link to comment
Share on other sites

You can try something like this.

 

 

<?php
if(isset($_GET['p'])){ $page = $_GET['p']; }
if(strpos($page,"\.") || strpos($page,"/") || strpos($page,"\\")){ $page = "";} //Check for illegal characters

switch($page){
	case "login":
	$page = HTML_ROOT."/login.php";
	break;
case "about":
	$page = HTML_ROOT."/about.php";
	break;
case "admin":
	$page = HTML_ROOT."/admincp.php";
	break;
default:
	$page = HTML_ROOT. "/welcome.html";
}

if(file_exists($page)){
  include_once($page);
}else{
echo "The requested page is not available.";
}

?>

 

Then just include that on your master page.  In the content area.

 

You can have things navigate by using url queries.

 

<div id="menu">
			<ul>
				<li><a href="/index.php">: Home :</a></li>
				<li><a href="./?p=about">: About :</a></li>
				<li class="right"><a href="./?p=login">: Login :</a></li>
			</ul>
</div><!--end: menu-->

Link to comment
Share on other sites

Hi:

 

Thanks for giving me some direction.

 

So, would this line:

include_once($page);

 

be the page I posted? Does it get pulled into this in that manner? Do I need to re-arrange my database to add a "case/page" field?

 

I'm a little uncertain how all of this is suppose to work.

 

I guess the idea is to use the form/page I posted only once, and create a navigation to recognize it by "case/page" IDs ???

 

Sorry, I'm a little confused.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.