Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if !isset multiple OR conditions

Tags:

php

I cannot get this to work for the life of me, it is PHP.

<?php
 if (!isset($_POST['ign']) || ($_POST['email'])) {

  echo "Please enter all of the values!";
    }

 else {

   echo "Thanks, " . $_POST['ign'] . ", you will recieve an email when the site is         complete!";

    }
    ?>

I've also tried using !isset twice.

like image 611
Depetrify Avatar asked Jan 09 '12 06:01

Depetrify


People also ask

What is isset ($_ GET?

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.

What is if isset ($_ POST submit )) in PHP?

isset( $_POST['submit'] ) : This line checks if the form is submitted using the isset() function, but works only if the form input type submit has a name attribute (name=”submit”).

Why Isset is used in PHP?

The isset function in PHP is used to determine whether a variable is set or not. A variable is considered as a set variable if it has a value other than NULL. In other words, you can also say that the isset function is used to determine whether you have used a variable in your code or not before.

Does Isset check for empty?

The isset() function is an inbuilt function in PHP that is used to determine if the variable is declared and its value is not equal to NULL. The empty() function is an inbuilt function in PHP that is used to check whether a variable is empty or not.


1 Answers

This is how I solved this issue:

$expression = $_POST['ign'] || $_POST['email'] ;
if (!isset($expression) {
    echo "Please enter all of the values!";
}
else {
     echo "Thanks, " . $_POST['ign'] . ", you will recieve an email when the site is                              
              complete!";
}
like image 140
sah Avatar answered Sep 27 '22 23:09

sah