0

table
user->user_id, username, etc
image->image_id, user_id, image, etc
i am making a delete image page where user can del there image. i want to some how test image is the user who is loged in.

1st check user is loged in

if(isset($_SESSION['username']))  

2nd check user hit sumbit button

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

3rd check image is user who is loged in.

$user_id_s = $_SESSION['user_id'];  //get user id who is loged in
$image_id_g = $_POST['random'];   //get image id of the page
//if(no check that user_id_s is same line of image_id_g)  neeeeeeeeeeeeed help here
mysqlquery("SELECT image_id FROM image WHERE ???");





full code
























    <?php
    include("include/header.php");

    //check, if user is loged in or not
    if(isset($_SESSION['username']))      /*** user is loged in ***/
    {
        if($_SERVER['REQUEST_METHOD'] == 'POST')     //user hit submit button
        {
            $image_id_g = $_POST['random'];

            $del_image = mysql_query("DELETE FROM image WHERE image_id = '$image_id_g'");
            $del_comment = mysql_query("Delete From comment Where image_id = '$image_id_g'");

            header('Location: gallery.php');    
        }
    }
    else
    {
        header('Location: error.php');  
    }
    ?>

Edited by hwoarang69

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by hwoarang69
1

ok if you make the select than you should trageted for the user that has that image this is my opinion

1

mysqlquery("SELECT image_id FROM image WHERE ???");

Why not :
mysqlquery("SELECT image_id FROM image WHERE user_id = $_SESSION['user_id']");

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.