Location: PHPKode > projects > FreePHPShoppingCartSoftware > admin_users.inc
<?php

// =======================================================================
// Module name: Admin Users
// File name: admin_users.inc
// Version: 1.0
// Description: This script contains php code for the admin users module.
// This module is pre-installed with the program and can not be
// uninstalled, as it is a vital module to the admin backend of the
// program. This module allows users with administrator rights to add,
// manage, search, and delete admin interface user accounts.
// 
// Comments are included within this script to document changes made to
// the code with each new version of the script. Each comment also lists
// the author's initials to document who made the changes to the code.
//
// Copyright (C) 2006-2010 Dustin Cowell Enterprises
//
// License: GNU General Public License, Version 2
//
// Link: http://www.gnu.org/licenses/gpl-2.0.txt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to:
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA  02110-1301 USA
// =======================================================================

// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================

if ($request == "run_install" and $install_type == "express" and $admin_rights == "Admin") {

	$db_create_admin_users = "CREATE TABLE admin_users (" . 
		"id int not null auto_increment primary key, " . 
		"first_name text, " . 
		"last_name text, " . 
		"email_address text, " . 
		"password text, " . 
		"rights text " . 
		")";

	$db_insert_admin_users = "INSERT INTO admin_users SET " . 
		"first_name = '$first_name', " . 
		"last_name = '$last_name', " . 
		"email_address = '$email_address', " . 
		"password = '$password', " . 
		"rights = 'Admin'";

	echo("<tr>");
	echo("<td>" . $font_body . "Create Users</font></td>");
	echo("<td>" . $font_body);
	if (@mysql_query($db_create_admin_users)) {
		echo("Successful");
	} else {
		echo("Error");
	}
	echo("</font></td>");
	echo("</tr>");
		echo("<tr>");
	echo("<td>" . $font_body . "Insert Admin User</font></td>");
	echo("<td>" . $font_body);
	if (@mysql_query($db_insert_admin_users)) {
		echo("Successful");
	} else {
		echo("Error");
	}
	echo("</font></td>");
	echo("</tr>");

}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and !$request and $admin_rights == "Admin") {
	echo("<b>Users</b><p>");

	$order_by = $_GET['order_by'];
	$sort = $_GET['sort'];

	$db_lookup_admin_users = @mysql_query("SELECT id FROM admin_users");
	$db_admin_users = @mysql_fetch_array($db_lookup_admin_users);
	$db_admin_users_id = $db_admin_users['id'];

	if ($db_admin_users_id) {

		// ==================== START OF PAGE # HEADER ====================

		if ($_POST["results_per_page"]) {
			$results_per_page  = $_POST["results_per_page"];
			$_SESSION['results_per_page'] = $results_per_page;
		} else {
			if (!$_SESSION['results_per_page']) {
				$results_per_page=10;
			}
		}

		if ($_GET["start_page"]) {
			$start_page  = $_GET["start_page"];
		} else {
			$start_page=1;
		}
		$start_from = ($start_page-1) * $results_per_page; 

		echo("<p>");
		echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
		echo("<tr>");
		echo("<td align='left' width='50%'>" . $font_body);

		echo "<b>Pages:&nbsp;&nbsp;";

		$db_count_admin_users = @mysql_query("SELECT COUNT(id) FROM admin_users"); 
		$row = @mysql_fetch_row($db_count_admin_users); 
		$total_records = $row[0]; 
		$total_start_pages = ceil($total_records / $results_per_page); 

		for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
			if ($page_number == $start_page) {
				echo "$page_number&nbsp;&nbsp;";
			} else {
				echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=users&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a>&nbsp; ";
			}
		}
		echo "</b>";

		echo("</td>");
		echo("<td align='left' width='50%'>" . $font_body);

		echo("<table border='0' cellpadding='2' cellspacing='0'>");
		echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&start_page=".$start_page."' method='post'>");
		echo("<tr>");
		echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
		echo("<td>" . $font_body . "");
		echo("<select size='1' name='results_per_page'>");
		if ($results_per_page == 10) {
			echo("<option value='10' selected>10</option>");
		} else {
			echo("<option value='10'>10</option>");
		}
		if ($results_per_page == 25) {
			echo("<option value='25' selected>25</option>");
		} else {
			echo("<option value='25'>25</option>");
		}
		if ($results_per_page == 50) {
			echo("<option value='50' selected>50</option>");
		} else {
			echo("<option value='50'>50</option>");
		}
		if ($results_per_page == 100) {
			echo("<option value='100' selected>100</option>");
		} else {
			echo("<option value='100'>100</option>");
		}
		if ($results_per_page == 99999) {
			echo("<option value='99999' selected>All</option>");
		} else {
			echo("<option value='99999'>All</option>");
		}
		echo("</select>");
		echo("</font></td>");
		echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
		echo("</tr>");
		echo("</form>");
		echo("</table>");

		echo("</td>");
		echo("</tr>");
		echo("</table>");

		// ==================== END OF PAGE # HEADER ====================

		echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=new_user'>" . $link_color . "New</font></a>]&nbsp;");
		echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=search_users'>" . $link_color . "Search</font></a>]<p>");
		echo("<table border='0' cellpadding='5' cellspacing='0'>");
		echo("<tr>");
		if (!$sort or $sort == "DESC") { 
			echo("<td>" . $font_body . "<b><a href='" . $_SERVER['PHP_SELF'] . "?page=users&order_by=first_name&sort=ASC'>" . $link_color . "First Name</font></a></b></td>");
			echo("<td>" . $font_body . "<b><a href='" . $_SERVER['PHP_SELF'] . "?page=users&order_by=last_name&sort=ASC'>" . $link_color . "Last Name</font></a></b></td>");
			echo("<td>" . $font_body . "<b><a href='" . $_SERVER['PHP_SELF'] . "?page=users&order_by=email_address&sort=ASC'>" . $link_color . "Email Address</font></a></b></td>");
			echo("<td>" . $font_body . "<b>Actions</b></td>");
		}
		if ($sort == "ASC") {
			echo("<td>" . $font_body . "<b><a href='" . $_SERVER['PHP_SELF'] . "?page=users&order_by=first_name&sort=DESC'>" . $link_color . "First Name</font></a></b></td>");
			echo("<td>" . $font_body . "<b><a href='" . $_SERVER['PHP_SELF'] . "?page=users&order_by=last_name&sort=DESC'>" . $link_color . "Last Name</font></a></b></td>");
			echo("<td>" . $font_body . "<b><a href='" . $_SERVER['PHP_SELF'] . "?page=users&order_by=email_address&sort=DESC'>" . $link_color . "Email Address</font></a></b></td>");
			echo("<td>" . $font_body . "<b>Actions</b></td>");
		}
			echo("</tr>");
		
		$order_by = $_GET['order_by'];

		if ($order_by) {
			if ($sort) {
				$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address FROM admin_users ORDER BY $order_by $sort LIMIT $start_from, $results_per_page");
			} else {
				$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address FROM admin_users ORDER BY $order_by LIMIT $start_from, $results_per_page");
			}
		} else {
			$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address FROM admin_users ORDER BY id DESC LIMIT $start_from, $results_per_page");
		}
		
		while ($db_admin_users = @mysql_fetch_array($db_lookup_admin_users)) {
			
			$db_admin_users_id = $db_admin_users['id'];
			$db_admin_users_first_name = $db_admin_users['first_name'];
			$db_admin_users_last_name = $db_admin_users['last_name'];
			$db_admin_users_email_address = $db_admin_users['email_address'];

			echo("<tr>");
			echo("<td>" . $font_body . $db_admin_users_first_name . "</td>");
			echo("<td>" . $font_body . $db_admin_users_last_name . "</td>");
			echo("<td>" . $font_body . $db_admin_users_email_address . "&nbsp;</td>");
			echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=view_user&admin_users_id=$db_admin_users_id'>" . $link_color . "View</font></a>]&nbsp;[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=edit_user&admin_users_id=$db_admin_users_id'>" . $link_color . "Edit</font></a>]&nbsp;[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=delete_user&admin_users_id=$db_admin_users_id'>" . $link_color . "Delete</font></a>]</td>");
			echo("</tr>");
		}
		echo("</table>");
		echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=new_user'>" . $link_color . "New</font></a>]&nbsp;");
		echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=search_users'>" . $link_color . "Search</font></a>]");

		// ==================== START OF PAGE # FOOTER ====================

		echo("<p>");
		echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
		echo("<tr>");
		echo("<td align='left' width='50%'>" . $font_body);

		echo "<b>Pages:&nbsp;&nbsp;";

		$db_count_admin_users = @mysql_query("SELECT COUNT(id) FROM admin_users"); 
		$row = @mysql_fetch_row($db_count_admin_users); 
		$total_records = $row[0]; 
		$total_start_pages = ceil($total_records / $results_per_page); 

		for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
			if ($page_number == $start_page) {
				echo "$page_number&nbsp;&nbsp;";
			} else {
				echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=users&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a>&nbsp; ";
			}
		}
		echo "</b>";

		echo("</td>");
		echo("<td align='left' width='50%'>" . $font_body);

		echo("<table border='0' cellpadding='2' cellspacing='0'>");
		echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&start_page=".$start_page."' method='post'>");
		echo("<tr>");
		echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
		echo("<td>" . $font_body . "");
		echo("<select size='1' name='results_per_page'>");
		if ($results_per_page == 10) {
			echo("<option value='10' selected>10</option>");
		} else {
			echo("<option value='10'>10</option>");
		}
		if ($results_per_page == 25) {
			echo("<option value='25' selected>25</option>");
		} else {
			echo("<option value='25'>25</option>");
		}
		if ($results_per_page == 50) {
			echo("<option value='50' selected>50</option>");
		} else {
			echo("<option value='50'>50</option>");
		}
		if ($results_per_page == 100) {
			echo("<option value='100' selected>100</option>");
		} else {
			echo("<option value='100'>100</option>");
		}
		if ($results_per_page == 99999) {
			echo("<option value='99999' selected>All</option>");
		} else {
			echo("<option value='99999'>All</option>");
		}
		echo("</select>");
		echo("</font></td>");
		echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
		echo("</tr>");
		echo("</form>");
		echo("</table>");

		echo("</td>");
		echo("</tr>");
		echo("</table>");

		// ==================== END OF PAGE # FOOTER ====================

	} else {
		echo("No users were found in the database.");

		echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=new_user'>" . $link_color . "New</font></a>]<p>;");
	}
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "new_user" and $admin_rights == "Admin") {
	echo("<b>Users - New User</b><p>");
	echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&request=new_user_submit' method='post'>");
	echo("<table border='0' cellpadding='5' cellspacing='0'>");
	echo("<tr>");
	echo("<td>" . $font_body . "First Name:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='first_name'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Last Name:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='last_name'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Email Address:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='email_address'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Password:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='password'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Rights:</font></td>");
	echo("<td>" . $font_body . "");
	echo("<select name='rights'>");
	echo("<option value='Admin'>Admin</option>");
	echo("<option value='User'>User</option>");
	echo("</select>");
	echo("</font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "&nbsp;</font></td>");
	echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
	echo("</tr>");
	echo("</table>");
	echo("</form>");

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "new_user_submit" and $admin_rights == "Admin") {
	echo("<b>Users - New User</b><p>");
	
	$first_name = $_POST['first_name'];
	$last_name = $_POST['last_name'];
	$email_address = $_POST['email_address'];
	$password = $_POST['password'];
	$rights = $_POST['rights'];
	
	$db_insert = "INSERT INTO admin_users SET " . 
		"first_name = '$first_name', " .  
		"last_name = '$last_name', " . 
		"email_address = '$email_address', " . 
		"password = '$password', " . 
		"rights = '$rights'";

	if (@mysql_query($db_insert)) {
		echo($first_name . " " . $last_name . " has been added to the database.");
	} else {
		echo("Error adding user to the database.");
	}

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "view_user" and $admin_rights == "Admin") {
	echo("<b>Users - View User</b><p>");
	
	$admin_users_id = $_GET['admin_users_id'];
	
	$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address, password, rights FROM admin_users WHERE id='$admin_users_id'");
	$db_admin_users = @mysql_fetch_array($db_lookup_admin_users);
	
	$db_admin_users_id = $db_admin_users['id'];
	$db_admin_users_first_name = $db_admin_users['first_name'];
	$db_admin_users_last_name = $db_admin_users['last_name'];
	$db_admin_users_email_address = $db_admin_users['email_address'];
	$db_admin_users_password = $db_admin_users['password'];
	$db_admin_users_rights = $db_admin_users['rights'];
	
	echo("<table border='0' cellpadding='5' cellspacing='0'>");
	echo("<tr>");
	echo("<td>" . $font_body . "First Name:</td>");
	echo("<td>" . $font_body . "" . $db_admin_users_first_name . "</td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Last Name:</td>");
	echo("<td>" . $font_body . "" . $db_admin_users_last_name . "</td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Email Address:</td>");
	echo("<td>" . $font_body . "" . $db_admin_users_email_address . "</td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Password</td>");
	echo("<td>" . $font_body . "" . $db_admin_users_password . "</td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Rights:</td>");
	echo("<td>" . $font_body . "" . $db_admin_users_rights . "</td>");
	echo("</tr>");
	echo("</table>");

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "edit_user" and $admin_rights == "Admin") {
	echo("<b>Users - Edit User</b><p>");
	
	$admin_users_id = $_GET['admin_users_id'];
	
	$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address, password, rights FROM admin_users WHERE id='$admin_users_id'");
	$db_admin_users = @mysql_fetch_array($db_lookup_admin_users);
	
	$db_admin_users_id = $db_admin_users['id'];
	$db_admin_users_first_name = $db_admin_users['first_name'];
	$db_admin_users_last_name = $db_admin_users['last_name'];
	$db_admin_users_email_address = $db_admin_users['email_address'];
	$db_admin_users_password = $db_admin_users['password'];
	$db_admin_users_rights = $db_admin_users['rights'];
	
	echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&request=edit_user_submit' method='post'>");
	echo("<input type='hidden' name='admin_users_id' value='$db_admin_users_id'>");
	echo("<table border='0' cellpadding='5' cellspacing='0'>");
	echo("<tr>");
	echo("<td>" . $font_body . "First Name:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='first_name' value='$db_admin_users_first_name'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Last Name:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='last_name' value='$db_admin_users_last_name'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Email Address:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='email_address' value='$db_admin_users_email_address'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Password:</font></td>");
	echo("<td>" . $font_body . "<input type='text' name='password' value='$db_admin_users_password'></font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "Rights:</font></td>");
	echo("<td>" . $font_body . "");
	echo("<select name='rights'>");
	if ($db_admin_users_rights == "Admin") {
		echo("<option value='Admin' selected>Admin</option>");
	} else {
		echo("<option value='Admin'>Admin</option>");
	}
	if ($db_admin_users_rights == "Author") {
		echo("<option value='Author' selected>Author</option>");
	} else {
		echo("<option value='Author'>Author</option>");
	}
	echo("</select>");
	echo("</font></td>");
	echo("</tr>");
	echo("<tr>");
	echo("<td>" . $font_body . "&nbsp;</font></td>");
	echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Update'></font></td>");
	echo("</tr>");
	echo("</table>");
	echo("</form>");

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "edit_user_submit" and $admin_rights == "Admin") {
	echo("<b>Users - Edit User</b><p>");
	
	$id = $_POST['admin_users_id'];
	$first_name = $_POST['first_name'];
	$last_name = $_POST['last_name'];
	$email_address = $_POST['email_address'];
	$password = $_POST['password'];
	$rights = $_POST['rights'];
	
	$db_insert = "UPDATE admin_users SET " . 
		"first_name = '$first_name', " .  
		"last_name = '$last_name', " . 
		"email_address = '$email_address', " . 
		"password = '$password', " . 
		"rights = '$rights' " . 
	    "WHERE id = '$id'";
	
	if (@mysql_query($db_insert)) {
		echo($first_name . " " . $last_name . "'s user information has been updated.");
	} else {
		echo("Error updating user information.");
	}

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "delete_user" and $admin_rights == "Admin") {
	echo("<b>Users - Delete User</b><p>");

	$admin_users_id = $_GET['admin_users_id'];
	
	$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address, password, rights FROM admin_users WHERE id='$admin_users_id'");
	$db_admin_users = @mysql_fetch_array($db_lookup_admin_users);
	
	$db_admin_users_id = $db_admin_users['id'];
	$db_admin_users_first_name = $db_admin_users['first_name'];
	$db_admin_users_last_name = $db_admin_users['last_name'];
	$db_admin_users_email_address = $db_admin_users['email_address'];
	$db_admin_users_password = $db_admin_users['password'];
	$db_admin_users_rights = $db_admin_users['rights'];

	echo("Are you sure you want to delete " . $db_admin_users_first_name . " " . $db_admin_users_last_name . "?<p>");
	echo("<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=delete_user_submit&admin_users_id=$db_admin_users_id'>" . $link_color . "Yes</font></a> | ");
	echo("<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=delete_user_cancel&admin_users_id=$db_admin_users_id'>" . $link_color . "No</font></a>");

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "delete_user_submit" and $admin_rights == "Admin") {
	echo("<b>Users - Delete User</b><p>");
	
	$admin_users_id = $_GET['admin_users_id'];
	
	$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address, password, rights FROM admin_users WHERE id='$admin_users_id'");
	$db_admin_users = @mysql_fetch_array($db_lookup_admin_users);
	
	$db_admin_users_id = $db_admin_users['id'];
	$db_admin_users_first_name = $db_admin_users['first_name'];
	$db_admin_users_last_name = $db_admin_users['last_name'];
	$db_admin_users_email_address = $db_admin_users['email_address'];
	$db_admin_users_password = $db_admin_users['password'];
	$db_admin_users_rights = $db_admin_users['rights'];
	
	$db_delete_admin_user = @mysql_query("DELETE FROM admin_users WHERE id='$db_admin_users_id'");

	if ($db_delete_admin_user) {
		echo("" . $db_admin_users_first_name . " " . $db_admin_users_last_name . " <b><u>has</u></b> been deleted from the database.");
	} else {
		echo("Error deleting admin user.");
	}

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "delete_user_cancel" and $admin_rights == "Admin") {
	echo("<b>Users - Delete User</b><p>");
	
	$admin_users_id = $_GET['admin_users_id'];
	
	$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address, password, rights FROM admin_users WHERE id='$admin_users_id'");
	$db_admin_users = @mysql_fetch_array($db_lookup_admin_users);
	
	$db_admin_users_id = $db_admin_users['id'];
	$db_admin_users_first_name = $db_admin_users['first_name'];
	$db_admin_users_last_name = $db_admin_users['last_name'];
	$db_admin_users_email_address = $db_admin_users['email_address'];
	$db_admin_users_password = $db_admin_users['password'];
	$db_admin_users_rights = $db_admin_users['rights'];

	echo("" . $db_admin_users_first_name . " " . $db_admin_users_last_name . " <b><u>has not</u></b> been deleted from the database.");

	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "search_users" and $admin_rights == "Admin") {
	echo("<b>Users - Search Users</b><p>");

	echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&request=search_users_submit' method='post'>");
	echo("<table border='0' cellpadding='5' cellspacing='0'");
	echo("<tr>");
	echo("<td valign='top' align='left'>" . $font_body . "First name: </td></font>");
	echo("<td>" . $font_body . " ");
	echo("<input type='text' name='first_name'> ");
	echo("</td>");
	echo("<td>" . $font_body . " ");
	echo("<input type='submit' name ='submit' value ='Search'>");
	echo("</td>");
	echo("</tr>");
	echo("</form>");
	echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&request=search_users_submit' method='post'>");
	echo("<tr>");
	echo("<td valign='top' align='left'>" . $font_body . "Last name: </td></font>");
	echo("<td>" . $font_body . " ");
	echo("<input type='text' name='last_name'> ");
	echo("</td>");
	echo("<td>" . $font_body . " ");
	echo("<input type='submit' name ='submit' value ='Search'>");
	echo("</td>");
	echo("</tr>");
	echo("</form>");
	echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=users&request=search_users_submit' method='post'>");
	echo("<tr>");
	echo("<td valign='top' align='left'>" . $font_body . "Email Address: </td></font>");
	echo("<td>" . $font_body . " ");
	echo("<input type='text' name='email_address'> ");
	echo("</td>");
	echo("<td>" . $font_body . " ");
	echo("<input type='submit' name ='submit' value ='Search'>");
	echo("</td>");
	echo("</tr>");
	echo("</form>");
	echo("</table>");
	echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users'>" . $link_color . "Users</font></a>]<p>");
}

// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================

if ($page == "users" and $request == "search_users_submit" and $admin_rights == "Admin") {
	echo("<b>Users - Search Users</b><p><p>");

	$first_name = $_POST['first_name'];
	$last_name = $_POST['last_name'];
	$email_address = $_POST['email_address'];

	if ($first_name) {
			$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address FROM admin_users WHERE first_name='$first_name' ORDER BY id DESC");
	}
	if ($last_name) {
			$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address FROM admin_users WHERE last_name='$last_name' ORDER BY id DESC");
	}
	if ($email_address) {
			$db_lookup_admin_users = @mysql_query("SELECT id, first_name, last_name, email_address FROM admin_users WHERE email_address='$email_address' ORDER BY id DESC");
	}

	if ($db_lookup_admin_users) {
		echo("<table border='0' cellpadding='5' cellspacing='0'>");
		echo("<tr>");
		echo("<td>" . $font_body . "<b>First Name</b></td>");
		echo("<td>" . $font_body . "<b>Last Name</b></td>");
		echo("<td>" . $font_body . "<b>Email Address</b></td>");
		echo("<td>" . $font_body . "<b>Actions</b></td>");
		echo("</tr>");

		while ($db_admin_users = @mysql_fetch_array($db_lookup_admin_users)) {
			$db_admin_users_id = $db_admin_users['id'];
			$db_admin_users_first_name = $db_admin_users['first_name'];
			$db_admin_users_last_name = $db_admin_users['last_name'];
			$db_admin_users_email_address = $db_admin_users['email_address'];

			echo("<tr>");
			echo("<td>" . $font_body . $db_admin_users_first_name . "</td>");
			echo("<td>" . $font_body . $db_admin_users_last_name . "</td>");
			echo("<td>" . $font_body . $db_admin_users_email_address . "&nbsp;</td>");
			echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=view_user&admin_users_id=$db_admin_users_id'>" . $link_color . "View</font></a>]&nbsp;[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=edit_user&admin_users_id=$db_admin_users_id'>" . $link_color . "Edit</font></a>]&nbsp;[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=delete_user&admin_users_id=$db_admin_users_id'>" . $link_color . "Delete</font></a>]</td>");
			echo("</tr>");
		}
		echo("</table>");
	} else {
		echo("Sorry, there were no results found matching $first_name $last_name $email_address");
	}
	echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=users&request=search_users'>" . $link_color . "Search Users</font></a>]<p>");
}

?>
Return current item: FreePHPShoppingCartSoftware