0

I have simple restful api with php

<?php
    require "../ConfigBaza.php";

    $proizvodid = $_GET['proizvodid'];
    $naziv = $_GET['naziv'];
    $pdv = $_GET['pdv'];
    $aa = $_GET['akcijski_artikal'];
    $a = $_GET['aktivan'];
    $slika = $_GET['slika'];
    $jm = $_GET['jm'];
    $opis = $_GET['opis'];
    $katbr = $_GET['katbr'];

    $sql = "INSERT INTO Proizvod (PROIZVODID, NAZIV, PDV, AKCIJSKI_ARTIKAL, AKTIVAN, SLIKA, JM, OPIS, KATBR) VALUES ('$proizvodid', '$naziv', '$pdv', '$aa', '$a', '$slika', '$jm', '$opis', '$katbr')";

    if($mysqli->query($sql))
    {
        echo("1");
    }
    else
    {
        echo("0" . "<br>");
        echo("PROIZVODID = " . $proizvodid . "<br>");
        echo("NAZIV = " . $naziv . "<br>");
        echo("PDV = " . $pdv . "<br>");
        echo("Akcijski Artikal = " . $aa . "<br>");
        echo("Aktivan = " . $a . "<br>");
        echo("SLIKA = " . $slika . "<br>");
        echo("JM = " . $jm . "<br>");
        echo("OPIS = " . $opis . "<br>");
        echo("KATBR = " . $katbr . "<br>");
    }
?>

And when i enter url like this:

/Php/Proizvodi/Novi.php?proizvodid=3410&naziv=REVIZIJA%20200*200%20GIPS&pdv=20&akcijski_artikal=1&aktivan=1&slika=&katbr=74-1800%20P%20#2.012N3IZ&jm=kom&opis=Revizioni%20otvor

It doesn't execute sql and for some reason jm returns blank and opis returns blank even if doesn't need to.

Pacijent
  • 139
  • 1
  • 12
  • 5
    Possible duplicate of [Why is the hash part of the URL not available on the server side?](https://stackoverflow.com/questions/3664257/why-is-the-hash-part-of-the-url-not-available-on-the-server-side) – Nigel Ren Aug 14 '18 at 08:28
  • There is no URL parameter named `opis` or `jm`. Everything after the hashmark is an anchor target, not a URL parameter. So `2.012N3IZ&jm=kom&opis=Revizioni%20otvor` will not get parsed as parameters. – feeela Aug 14 '18 at 08:46

1 Answers1

0

I think you might be looking for something along these lines https://www.designcise.com/web/tutorial/how-to-get-key-value-pair-from-url-query-string-in-php

In this example they use parse_str($_SERVER['QUERY_STRING'], $output); to get the raw values without url encoding.

I believe it is to do with having the # in the url string.

The server can't access the variables beyond the #, they are only accessible from the front end.

Hope this helps.