Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:12:00+00:00 2026-06-04T01:12:00+00:00

I wonder whether someone may be able to help me please. The code below

  • 0

I wonder whether someone may be able to help me please.

The code below allows users to delete images from a gallery.

Full Script Minus Styling

 <?php session_start(); 

$_SESSION['userid']=$_POST['userid'];
$_SESSION['locationid']=$_POST['locationid'];

//echo $_SESSION['userid']; 
//echo $_SESSION['locationid'];
?>
<?php 

  $galleryPath = 'UploadedFiles/' . $_SESSION['userid'] . '/' . $_SESSION['locationid'] . '/';

  $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; 

  $descriptions = new DOMDocument('1.0'); 
  $descriptions->load($absGalleryPath . 'files.xml'); 
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=0.3">
        <title>Galleria Twelve Theme</title>
        <style>


        <script src="js/jquery-1.7.2.min.js"></script>
        <script src="js/jquery-ui-1.8.19.custom.min.js"></script>
        <script src="galleria/galleria-1.2.7.min.js"></script>
        <script src="galleria/themes/twelve/galleria.twelve.min.js"></script>
        <script src="galleria/plugins/history/galleria.history.min.js"></script>
        <link rel="stylesheet" href="galleria/themes/twelve/galleria.twelve.css">
         <style>

         .galleria-thumbnails .btn-delete {    
         display: block; /* Or just use a div instead of a span*/     
          position: absolute; bottom : 0px;  /*align at the bottom*/     
          width: 80px;     
          height: 17px;    
          cursor: pointer;     
          background: url(trash8.gif) no-repeat bottom; } 
         </style>

<script type="text/javascript"> 
Galleria.ready(function() { 
this.$('thumblink').click(); 

$(".galleria-image").append( 
"<span class='btn-delete ui-icon ui-icon-trash'></span>"); 

$(".btn-delete").live("click", function(){ 

// you do not need to find img and then src... just use id of image 
var img = $(this).closest(".galleria-image").find("img"); 

var userid=$(".hiddenvals").attr('userid'); 
var locationid=$(".hiddenvals").attr('locationid'); 

// send the AJAX request 
$.ajax({ 
url : 'delete3.php?userid='+userid+'&locationid='+locationid, 
type : 'post', 
data : { image : img.attr('src') }, 
success : function(){ 
alert('Deleting image... '); 
img.parent().fadeOut('slow'); 
} 
}); 

return false; 
}); 

}); 

</script> 



    </head>

<body>
<ul id="navigation">
<li class="left">
  <div align="center"><a href="javascript:document.viewimages.submit()" class="style2">&larr; Add Images</a></div>
</li>
</ul>
<form id="viewimages" name="viewimages" class="page" action="index.php" method="post"> <input name="userid" class="hiddenvals" type="hidden" value="<?php echo $_SESSION['userid']; ?>"> <input name="locationid" class="hiddenvals" type="hidden" value="<?php echo $_SESSION['locationid']; ?>"></form>
    <div class="content">
        <h1>Galleria Twelve Theme</h1>
        <p>Demonstrating a simple example.</p>

        <!-- Adding gallery images. We use resized thumbnails here for better performance, but it’s not necessary -->

        <div id="galleria">
          <?php for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) :  
                          $xmlFile = $descriptions->documentElement->childNodes->item($i);  
                          $name = htmlentities($xmlFile->getAttribute('originalname'), ENT_COMPAT, 'UTF-8');  
                          $description = htmlentities($xmlFile->getAttribute('description'), ENT_COMPAT, 'UTF-8');  
                          $source = $galleryPath . rawurlencode($xmlFile->getAttribute('source'));   
                  ?>
            <a href="<?php echo $source; ?>"><img data-title="<b>Image Name: </b> <?php echo $name; ?>" data-description="<b>Description:</b> <?php echo $description; ?>" src="<?php echo $source; ?>"></a>

      <?php endfor; ?>  
</body>
</html>

In essence, the user clicks on a delete icon, then the ‘delete.php’ script called in the code above deletes the image from the server. This all works well.

What I’m struggling with is how to pass two variable values to the ‘delete.php’ script. These are ‘userid’ and ‘locationid’.

I’ve tried adding the following to the beginning of my ‘delete.php’:

<?php session_start(); 

$_SESSION['userid']=$_POST['userid'];
$_SESSION['locationid']=$_POST['locationid'];

But the values are not carried over. I suspect that this may be down to the fact the the forms ‘POST’ action is being used to navigate to another HTML page, although I’m no expert, so I may have got this wrong.

I’ve done quite a bit of reading and searched for tutorials on how to go about getting around this problem, but I’ve not found anything that seems to suggest a solution.

I just wondered whether someone may be able to look at this please, and offers some guidance on how I can pass these two values to my ‘delete.php’ script.

Many thanks and kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:12:01+00:00Added an answer on June 4, 2026 at 1:12 am

    Try to send ids from your html page like

     $.ajax({
        url : 'delete.php?userid=2&locationid=4',
       ........
    

    Then in php

    $uid=$_POST['userid'];
    $locid=$_POST['locationid'];
    

    If you want to get userid and locationid dynamically for each image.

    FIRST; in you btn-delete class add uid and locid attribute. I suppose you are looping through PHP.

    LIKE ===>

    <input type="button" class="btn-delete" uid="2" locid="5">
    

    Then in your script

        <script type="text/javascript"> 
        Galleria.ready(function() {
        this.$('thumblink').click();
    
        $(".galleria-image").append( 
        "<span class='btn-delete ui-icon ui-icon-trash'></span>"); 
    
        $(".btn-delete").live("click", function(){
    
        // you do not need to find img and then src... just use id of image
        var img = $(this).closest(".galleria-image").find("img");
    
        var uid=$(this).attr('uid');
        var locid=$(this).attr('locid');
    
        // send the AJAX request
        $.ajax({
        url : 'delete.php?userid='+uid+'&locationid='+locid,
        type : 'post',
        data : { image : img.attr('src') },
        success : function(){
        alert('Deleting image... ');
        img.parent().fadeOut('slow');
        }
        });
    
        return false;
        });
    
        });
    
    </script>
    

    var id=$(this).attr(‘id’);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. From some demos
I wonder whether someone may be able to help me please. I'm using Aurigma
I wonder whether someone may be able to help. I've created an image gallery
I wonder whether someone may be able to help me please. Using some excellent
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help me please with a error
I wonder whether someone may be able to help me please. I'm trying to
I wonder whether someone may be able to help me please. Using Aurigma image
I wonder whether someone may be able to help me please. Firstly, apologies, I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.