Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16891

Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST"

From Jivanmukta <jivanmukta@poczta.onet.pl>
Newsgroups comp.lang.php
Subject Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST"
Date 2016-07-30 19:27 +0200
Organization Aioe.org NNTP Server
Message-ID <nnio1r$1n7i$1@gioia.aioe.org> (permalink)
References <892a3f04-5c3c-4b55-89c7-3b5e1b8bc879@googlegroups.com>

Show all headers | View raw


Alla wrote:
>     // else if the user is already at that form page and sees the form he
>     needs to fill in else if ($_SERVER["REQUEST_METHOD"] == "POST")
>     {
>         // validate submission
>         if (empty($_POST["username"]))
>         // do something

BTW, I have a question: how to write conditions "is screen_field empty?". If 
I write empty($_POST['screen_field']) I will receive TRUE for 
$_POST['screen_field'] === '0'. If screen_field is text input this makes a 
problem. Thus I wrote a function:

function is_empty($val) {
    if ($val === '0') {
        return FALSE;
    }
    if (is_string($val)) {
        $val = trim($val);
    }
    return empty($val);
}

and I use it for screen fields and database text values but I was criticised 
by PHP programmers that my solutions is not "PHP-way".

(Sorry for my English)

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

$_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST" Alla <modelling.data@gmail.com> - 2016-07-30 04:47 -0700
  Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST" "R.Wieser" <address@not.available> - 2016-07-30 14:36 +0200
    Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST" "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-30 14:48 +0200
      Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"]== "POST" "R.Wieser" <address@not.available> - 2016-07-30 15:38 +0200
        Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"]== "POST" Alla <modelling.data@gmail.com> - 2016-08-02 00:16 -0700
  Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST" Jivanmukta <jivanmukta@poczta.onet.pl> - 2016-07-30 19:27 +0200
    Re: $_SERVER["REQUEST_METHOD"] == "GET" vs $_SERVER["REQUEST_METHOD"] == "POST" Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-30 17:18 -0400

csiph-web