My account

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Fri Oct 26, 2012 4:00 pm

My account

Postby osborn99 » Fri Oct 26, 2012 4:37 pm

Hello, I've created a user photo gallery with php and sql. I have 2 tables photograph and users. At the moment it is very basic, when a user uploads a photo it shows as a thumbnail on the homepage. Only the admin (me) can delete photos. I want the user to click on my account or my profile.php and view just their own photos and be able to delete, view their photos. Here is my admin list_photos.php. What would I change so only the user can view his/her photos. I would like to set this up for the user as well.

Code: Select all

<?php require_once("../../includes/initialize.php"); ?>
<?php if (!$session->is_logged_in()) { redirect_to("login.php"); } ?>
  $photos = Photograph::find_all();
<?php include_layout_template('admin_header.php'); ?>


<?php echo output_message($message); ?>
<table class="bordered">
<?php foreach($photos as $photo): ?>
    <td><img src="../<?php echo $photo->image_path(); ?>" width="100" /></td>
    <td><?php echo $photo->filename; ?></td>
    <td><?php echo $photo->caption; ?></td>
    <td><?php echo $photo->size_as_text(); ?></td>
      <td><a href="delete_photo.php?id=<?php echo $photo->id; ?>">Delete</a></td>
<?php endforeach; ?>
<br />
<a href="photo_upload.php">Upload a new photograph</a>

<?php include_layout_template('admin_footer.php'); ?>

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 5 guests