Send hashtag parameter to another page in php

I am having problems with the send parameter with the hashtag (#) value in the HTTP request.

Example: I have matcontents #3232, then I need to send a parameter with this value. I tried to do this:

echo "<td width=25% align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Calibri' size='2'>
              <a href='../report/rptacc_det.php?kode=$brs3[matcontents]&fromd=$fromd2&tod=$tod2&type=$type&fty=$fty&nama=$brs3[itemdesc]' target='_blank'>
              $brs3[matcontents]</a></font></td>"; 

But when I call the code on rptacc_det.php, I have nothing or not. How to send a value, for example "# 3232" to another page?

+4
source share
1 answer

Anything after that is #not sent to the server in the request, since it is interpreted as a binding location on the page.

You can send them, but you need urlencodethem.

$kode = "this is a #test";

// Does not work:
// In the following, $_GET['parameter'] will be "this is a ";
// link will be '?kode=this is a #test'
echo '<a href=../report/rptacc_det.php?kode' . $kode . '>Click</a>'; 

// Works:
// In the following, $_GET['parameter'] will contain the content you need
// link will be '?kode=this%20is%20a%20%23test'
echo '<a href=../report/rptacc_det.php?kode' . urlencode($kode) . '>Click</a>';

To return the value to rptacc_det.php, you can useurldecode

$kode = urldecode($_GET['kode']);

You must do this with all the variables that you include in the URL.

+1
source

Source: https://habr.com/ru/post/1664268/


All Articles