-1

I got a challenge in which I have this code in a PHP file:

<?php
include('secretfile.php');
if(isset($_GET['a']) && isset($_GET['b']))
{
    $a = $_GET['a'];
    $b = $_GET['b'];

    if (!empty($a) && !empty($b))
    {
        if($a===$b)
        {

            if(isset($_GET['a⁡']) && isset($_GET['b⁦']))
            {
                $a = $_GET['a⁡'];
                $b = $_GET['b⁦'];
                if($a!==$b)
                {
                    echo $secretcode;
                }
            }
        }
    }
} 

I have to print secretcode in webpage with OUT changing the PHP file. How can I do it? I tried by giving parameters through URL like this:

http://127.0.0.1:8080/?a=1&b=1&a=22&b=33

But it didn't work. The file is taking the last values directly and no matter what, I couldn't go past the 13th line. I went through a lot of answers but I go no solution. Is it possible to do it? If yes, how?

Light Yagami
  • 961
  • 1
  • 9
  • 29
  • Why do you just repost the same question when it has already been closed (https://stackoverflow.com/questions/62484198/php-how-to-send-the-value-of-same-variable-twice-through-url-to-a-php-file now deleted). – Nigel Ren Jun 20 '20 at 11:14
  • If the duplicate doesn't answer your question, you can clarify what the issue is and perhaps it may help in getting an answer. – Nigel Ren Jun 20 '20 at 11:16

2 Answers2

0

To pass multiple values for a or b, you need to use the [] notation like below:

http://127.0.0.1:8080/?a[]=1&b[]=1&a[]=22&b[]=33

That being said, the PHP code in your file seems to be poorly written.

nice_dev
  • 17,053
  • 2
  • 21
  • 35
  • In such case, you have to change the PHP file to take arrays. Else, it won't work. – Light Yagami Jun 20 '20 at 11:11
  • @LightYagami There is no other way through a GET request with same key different values. By the way, what's the point of the script you shared? It checks for equality, does the same thing again and now it's expects them to be unequal for some reason. – nice_dev Jun 20 '20 at 12:22
0

To pass an array on html form you can use [] like

<form method="GET">
    <input type="text" name="a[]" />
    <input type="text" name="b[]" />
<form/>
Cvar1984
  • 13
  • 1
  • 4