Hi guys,
I wonder if you could help me out – I have created a index page at below:
What I want to achieve is: an index page for USER and ADMIN. The only different is ADMIN has all the priority of the page.
1.
For Admin they allow to edit, create user and delete the user and all.
For User / Member they only allow to view the page and create a new profile of they own.
For user they do not need these links:
Edit Link
Delete Link
The page is almost similar – can anyone help me to make this page reusable for admin_index.php as well as user_index.php – so we only come up with one page instead? Any suggestion would be appreciated.
Thanks.
admin.php
[code=php]
<?php
require ‘includes/application_top.php’;
$data = mysql_query (“SELECT persons.id, persons.name, persons.surname, persons.address, persons.mobile,
dept.dept_name FROM persons LEFT JOIN dept ON persons.dept_id = dept.id ORDER BY persons.id DESC”) or die (mysql_error());
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Friends Document</title>
</head>
<body>
<h1>Welcome to the admin page</h1>
<form action=”<?php echo $_SERVER[‘PHP_SELF’];?>” method=”post”>
<table width=”1000″ height=”60″ border=”0″ cellpadding=”3″>
<tr>
<td><a href=”newPerson.php?page=create”>Create User </a></td>
<td></td>
<td><a href=”logout.php?page=log_out”>Log Out</a></td>
</tr>
<table width=”808″ border=”1″ cellpadding=”3″>
<tr>
<th width=”17″>Id</th>
<th width=”89″>First Name</th>
<th width=”95″>Surname</th>
<th width=”160″>Address</th>
<th width=”84″>Department</th>
<th width=”105″>Phone</th>
<th width=”88″>Edit Link</th>
<th width=”86″>Delete Link</th>
</tr>
<?php
while($row = mysql_fetch_array( $data ))
{
?>
<tr>
<td><?php echo $row[‘id’];?></td>
<td>
<?php echo $row[‘name’];?>
<?php
if(isset($_GET[‘id’]) && (isset($_GET[‘page’]))) {
if($_GET[‘id’] == $row[‘id’] && $_GET[‘page’] == “create”){
echo “<div style=color:red;> Created</div>”;
//echo ‘<div style=”color: red;”> Created</div>’;
}
if($_GET[‘id’] == $row[‘id’] && $_GET[‘page’] == “modify”){
//echo “Modified”;
echo “<div style=color:red;> Modified</div>”;
}
}
?>
</td>
<!–Printing and pulling all the data–>
<td><?php echo $row[‘surname’];?></td>
<td><?php echo $row[‘address’];?></td>
<td><?php echo $row[‘dept_name’];?></td>
<td><?php echo $row[‘mobile’];?></td>
<!–modify.php?= (showing the id)–>
<!–td><a href = “newForm.php?id=<?php echo $row[‘id’];?>”>Modify User </a></td–>
<td><a href = “newPerson.php?id=<?php echo $row[‘id’];?>”>Modify User </a></td>
<td>
<a href= “deleteConfirm.php?id= <?php echo $row[‘id’];?>”>Delete User</a></td>
</tr>
<?php
}
?>
</table>
</form>
</body>
</html>