-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?

2
  • Why do you just repost the same question when it has already been closed (stackoverflow.com/questions/62484198/… now deleted). Commented Jun 20, 2020 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. Commented Jun 20, 2020 at 11:16

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

In such case, you have to change the PHP file to take arrays. Else, it won't work.
@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.
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/>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.