We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,394 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

mysqlquery not working

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');  
    }
    ?>
3
Contributors
4
Replies
3 Days
Discussion Span
11 Months Ago
Last Updated
5
Views
hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

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

dany12
Posting Whiz in Training
223 posts since Aug 2010
Reputation Points: 21
Solved Threads: 15
Skill Endorsements: 1

i not sure if i understant you

hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

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

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

Squidge
Posting Pro in Training
413 posts since Dec 2009
Reputation Points: 111
Solved Threads: 62
Skill Endorsements: 5

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

hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0735 seconds using 2.73MB