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');  
    }
    ?>

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

i not sure if i understant you

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

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

ah right. i was thinking some thing else. thanks alot squidge

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.