0

I have a URL like: https://website.org/withdraw.php?valid_addr=1333mwKE7EcwLaR9ztdtEt7pPEfafpW4nn&amount=0.0002&_unique=1

and A line of code that reads:

if (empty($_GET['amount']) || empty($_GET['valid_addr']) || empty($_GET['_unique']))==0) exit();

If I remove the line then the code runs successfully. Can anyone tell me what I've done wrong.

The line is supposed to stop the code from running if any of the three fields are left empty.

Thanks.

6 Answers 6

2

I think you want to utilize array_key_exists rather than empty.

if (!array_key_exists('amount', $_GET) || 
    !array_key_exists('valid_addr', $_GET) ||
    !array_key_exists('_unique', $_GET))
    exit();

From PHP empty() docs

Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.

See Array Key Exists docs

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

Comments

1
if (($_GET['amount'] == 0) OR ($_GET['valid_addr'] == 0) OR ($_GET['_unique'] == 0)) { exit(); }

Comments

0

Syntax Error. Remove the ==0) part:

if(empty($_GET['amount']) || empty($_GET['valid_addr']) || empty($_GET['_unique'])) {
    exit();
}

Comments

0

Left parenthesis missing,

   if ((empty($_GET['amount']) || empty($_GET['valid_addr']) || empty($_GET['_unique']))==0) exit();

Try it...

Comments

0

You're code should be something like this:

if (empty($_GET['amount']) || empty($_GET['valid_addr']) || empty($_GET['_unique']))
{
  exit();
}

Comments

0

Above your code has syntax error. I think you want to validate unique with 0 and 1. So you should have to try this code

if (empty($_GET['amount']) || empty($_GET['valid_addr']) || $_GET['_unique'])==0) exit();

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.