So i'm having a bit of a problem with having my PHP run a command if multiple variables exist. I made a simple version for people to see what i'm trying to fix easier. Thanks in advance to anyone who can help :)
<?php
if ((isset($finalusername)) && if (isset($finalpassword)) && if (isset($finalemail)))
echo "This will save.";
?>
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.
PHP $_GET is a PHP super global variable which is used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL. Assume we have an HTML page that contains a hyperlink with parameters: <html> <body>
When checking with the OR operator ( || ) the code will execute if one or none of them is empty. But you echo both variables even if one of them is empty. What I think you want to do is use the AND operator( && ). This way, the code will only execute if none of the variables are empty.
The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and is not NULL, otherwise it returns false.
if (isset($finalusername, $finalpassword, $finalemail))
Also see The Definitive Guide to PHP's isset
and empty
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With