不能通过url中的GET方法传递值为things.png的变量



我想通过GET发送4个值,像这样:

<a href="aksi_produk.php?module=produk&act=hapus&id=$r[id_produk]&namafile=$r[gambar]">
    Delete
</a>

URL应该是这样的

website/aksi_produk.php?module=produk&act=hapus&id=198&namafile=thing.png

但是看起来是这样的/aksi_produk.php?module=produk&act=hapus&id=198

我缺少一个值,即namafile。似乎我需要使用urlencode() ?但是我该怎么放,放在哪里呢?

编辑

这是

的完整代码
$no = $posisi+1;
while($r=mysqli_fetch_array($tampil)){
   $tanggal=tgl_indo($r[tgl_masuk]);
   $harga=format_rupiah($r[harga]);
   $namafile=urlencode($r[gambar]);
     echo "<tr><td>$no</td>
            <td>$r[nama_produk]</td>
            <td align=center>$r[harga]</td>
            <td align=center>$r[potongan]</td>
            <td align=center>$r[stok]</td>
            <td>$tanggal</td>
             <td><a 
               href=?module=produk&act=editproduk&id=$r[id_produk]><img src='images/icn_edit.png' title='Edit'>
                </a>  
              <a 
                 href=$aksi?module=produk&act=hapus&id=$r[id_produk]&namafile=$namafile><img src='images/icn_trash.png' title='delete'>
              </a>
       </td>
     </tr>";
  $no++;
}

请在传递变量之前进行编码。

$namafile=urlencode($r[gambar]);
<a href="aksi_produk.php?module=produk&act=hapus&id=$r[id_produk]&namafile=$namafile">
Delete
</a>

在发送页面,

$_GET["namafile"]
$file=urldecode($namafile);

看起来你需要添加引号和urlencode

<a href="aksi_produk.php?module=produk&act=hapus&id=<?php echo $r['id_produk'];?>&namafile=<?php echo urlencode($r['gambar']);?>">
Delete
</a>

您可以在使用任何算法编码后传递图像名称。

例如

$ namafile = base64_encode ($ r [gambar]);

当你访问这个值时,用base64_decode();

最新更新