Page 1 of 1

PHP/MYSQL Frontend

Posted: Tue Oct 26, 2010 10:46 am
by lostinthecode
Hi guys,

I finally got my website up and running how I want it to and am now working on getting an admin panel up and going to easily add/remove products from the database. I have got all the coding done and now I am having a problem getting it to work.

Here is the index.php file that connects to the database, all seems to be working right

Code: Select all

<?php

ob_start();

define('ROOTDIR', '/public_html/*******/');
set_include_path(ROOTDIR . ":" . ROOTDIR . "/library/:.:/usr/share/pear/");

date_default_timezone_set('America/Chicago');


$db = new mysqli("localhost", "username", "password", "dbname");
if (mysqli_connect_errno()) 
	error (503, $_SERVER["REDIRECT_URL"]);
$db->query("SET NAMES utf8");

function error($type, $request)
{
	if ($type == 404) {
		header("HTTP/1.1 404 Not Found");
		header("Location: /error.php?error=404&request={$request}");
	} elseif ($type == 403) {
		header("HTTP/1.1 403 Unauthorized");
		header("Location: /login{$request}");
	} elseif ($type == 503) {
		header('HTTP/1.1 503 Service Temporarily Unavailable');
		header('Status: 503 Service Temporarily Unavailable');
		header('Retry-After: 3600');
		header("Location: /error.php?error=503&request={$request}");
	}
	ob_end_flush();
	exit();
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Administration Control Panel</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<link rel="stylesheet" href="/admin.css" type="text/css" media="all">
	<link rel="stylesheet" href="/invoice.css" type="text/css" media="all">
</head>

<body>
<div id="heading">
	<table width="100%">
		<colgroup>
			<col width="20%">
			<col width="20%">
			<col width="20%">
			<col width="20%">
			<col width="20%">
		</colgroup>
		<tr>
			<td>
				<h2>Sales / Orders</h2>
				<ul>
					<li><a href="/?m=orders">Orders</a></li>
					<li><a href="/?m=payment">Payments</a></li>
					<li><a href="/?m=user">Users / Customers</a></li>
					<li><a href="/?m=news">News Articles</a></li>
				</ul>
			</td>
			<td>
				<h2>Catalog Data</h2>
				<ul>
					<li><a href="/?m=manufacturer">Manufacturers</a></li>
					<li><a href="/?m=category">Categories</a></li>
					<li><a href="/?m=attribute">Attributes</a></li>
					<li><a href="/?m=status">Status</a></li>
				</ul>
			</td>
			<td>
				<h2>Product Info</h2>
				<ul>
					<li><a href="/?m=product">Products</a></li>
					<li><a href="/?m=prodattr">Product Attributes</a></li>
					<li><a href="/?m=package">Packages</a></li>
					<li><a href="/?m=relation">Relations</a></li>
				</ul>
			</td>
			<td>
				<h2>Inventory</h2>
				<ul>
					<li><a href="/?m=pricing">Pricing</a></li>
					<li><a href="/?m=import">Import</a></li>
					<li><a href="/?m=davidsons">Davidsons</a></li>
					<li><a href="/?m=gunbroker">Gunbroker</a></li>
				</ul>
			</td>
			<td>
				<h2>Expert Level</h2>
				<ul>
					<li><a href="https://www.google.com/analytics/">Google Analytics</a></li>
					<li><a href="https://www.google.com/webmasters/">Google Webmasters</a></li>
					<li><a href="/?m=google">Google Products</a></li>
					<li><a href="/?m=sitemap">Sitemap Generation</a></li>
				</ul>
			</td>
		</tr>
	</table>
</div>

<div id="pagebody">
	<div class="box-wrapper fullpage">
		<div id="main" class="box-one">

<div id="staff">
<?php

$module = "default";
if (! empty($_GET["m"])) $module = addslashes($_GET["m"]);
if ((empty($module)) || (! ctype_alnum($module))) $module = "default";

if (file_exists(ROOTDIR . "staff/templates/{$module}.phtml")) {
	require_once("staff/templates/{$module}.phtml");
} else {
	error_log("Admin sending 404 for {$module}");
	error(404, $request);
}

?>
</div>

		</div>
	</div>
</div>

</body>
</html>
There are a ton more files that could be causing the problem but I'm thinking that it has to do something with this or the .htaccess/.htpasswd file.

Bascically when I login instead of taking me to the control panel it takes me to the the main page of the website instead of the admin page, I was hoping that someone here can help me or point me in the right direction. Also if I cannot get around this problem, I would be willing to pay a scripter to code a minimalist admin panel for the mysql database. Thanks in advance for any help.