Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. PHP form processing: the easy way

PHP form processing: the easy way

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpphpquestion
14 Posts 9 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P predicador

    An ex-coworker asked me to help him with his first website (maybe last?). It's for a real estate agency. He was stuck trying to process the search form with some selects (price range, state size, zone location, bla, bla.. ) All the code is a fucking mess, but this piece of crap excels among all other:

    $filter='';
    $type=$_POST['type']; // Home, Flat...
    $admin=$_POST['admin']; // Buy, Rent
    $zone=$_POST['zone']; // Situation area
    $m2=$_POST['m2']; // Size, stands for square meter
    $price=$_POST['price'];

        if(($type!="selec") AND ($admin!="selec") AND ($zone!="selec") AND ($m2!="selec") AND ($price!="selec")){
        $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\" AND city=\\"$city\\"";
        }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($pricemax!="")){
        $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\"";
        }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($city!="")){
        $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND city=\\"$city\\"";
        }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemax!="") AND ($city!="")){
        $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
        }elseif(($type!="selec") AND ($pricemin!="") AND ($pricemax!="") AND ($city!="")){
        $filter="type=\\"$type\\" AND admin=\\"$pricemin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
        }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
        $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
        }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
        $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
        }elseif(($type!="selec") AND ($admin!="selec")){
        $filter="type=\\"$type\\" AND admin>=\\"$admin\\"";
        }elseif(($type!="selec") AND ($pricemin!="")){
        $filter="type=\\"$type\\" AND price>=\\"$pricemin\\"";
        }elseif(($type!="selec") AND ($pricemax!="")){
        $filter="type=\\"$type\\" AND price>=\\"$pricemax\\"";
        }elseif(($type!="selec") AND ($city!="")){
        $filter="type=\\"$type\\" AND city>=\\"$city\\"";
        }elseif($type!="selec"){
        $filter="type=\\"$type\\"";
        }elseif($admin!="selec"){
        $filter="admin=\\"$a
    
    M Offline
    M Offline
    musefan
    wrote on last edited by
    #5

    ahhh crap, I think I just had a stroke X|

    I may or may not be responsible for my own actions

    1 Reply Last reply
    0
    • P Peter_in_2780

      The ability to write total garbage is language- (and culture-) independent. ;P X| with the possible exception of APL, where nobody can tell if it's garbage or clever code. Described to me years ago as the world's first write-only language. Cheers, Peter

      Software rusts. Simon Stephenson, ca 1994.

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #6

      No exception, it's possible to write good and bad APL, or even J. The problem is that it has more features, so it's easier to abuse, and a lot of it is written by academics who don't really believe in professional software practices.

      1 Reply Last reply
      0
      • P predicador

        An ex-coworker asked me to help him with his first website (maybe last?). It's for a real estate agency. He was stuck trying to process the search form with some selects (price range, state size, zone location, bla, bla.. ) All the code is a fucking mess, but this piece of crap excels among all other:

        $filter='';
        $type=$_POST['type']; // Home, Flat...
        $admin=$_POST['admin']; // Buy, Rent
        $zone=$_POST['zone']; // Situation area
        $m2=$_POST['m2']; // Size, stands for square meter
        $price=$_POST['price'];

            if(($type!="selec") AND ($admin!="selec") AND ($zone!="selec") AND ($m2!="selec") AND ($price!="selec")){
            $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\" AND city=\\"$city\\"";
            }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($pricemax!="")){
            $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\"";
            }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($city!="")){
            $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND city=\\"$city\\"";
            }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemax!="") AND ($city!="")){
            $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
            }elseif(($type!="selec") AND ($pricemin!="") AND ($pricemax!="") AND ($city!="")){
            $filter="type=\\"$type\\" AND admin=\\"$pricemin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
            }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
            $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
            }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
            $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
            }elseif(($type!="selec") AND ($admin!="selec")){
            $filter="type=\\"$type\\" AND admin>=\\"$admin\\"";
            }elseif(($type!="selec") AND ($pricemin!="")){
            $filter="type=\\"$type\\" AND price>=\\"$pricemin\\"";
            }elseif(($type!="selec") AND ($pricemax!="")){
            $filter="type=\\"$type\\" AND price>=\\"$pricemax\\"";
            }elseif(($type!="selec") AND ($city!="")){
            $filter="type=\\"$type\\" AND city>=\\"$city\\"";
            }elseif($type!="selec"){
            $filter="type=\\"$type\\"";
            }elseif($admin!="selec"){
            $filter="admin=\\"$a
        
        J Offline
        J Offline
        Johann Gerell
        wrote on last edited by
        #7

        "One can write Fortran in any language."

        Time you enjoy wasting is not wasted time - Bertrand Russel

        1 Reply Last reply
        0
        • P predicador

          An ex-coworker asked me to help him with his first website (maybe last?). It's for a real estate agency. He was stuck trying to process the search form with some selects (price range, state size, zone location, bla, bla.. ) All the code is a fucking mess, but this piece of crap excels among all other:

          $filter='';
          $type=$_POST['type']; // Home, Flat...
          $admin=$_POST['admin']; // Buy, Rent
          $zone=$_POST['zone']; // Situation area
          $m2=$_POST['m2']; // Size, stands for square meter
          $price=$_POST['price'];

              if(($type!="selec") AND ($admin!="selec") AND ($zone!="selec") AND ($m2!="selec") AND ($price!="selec")){
              $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\" AND city=\\"$city\\"";
              }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($pricemax!="")){
              $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\"";
              }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($city!="")){
              $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND city=\\"$city\\"";
              }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemax!="") AND ($city!="")){
              $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
              }elseif(($type!="selec") AND ($pricemin!="") AND ($pricemax!="") AND ($city!="")){
              $filter="type=\\"$type\\" AND admin=\\"$pricemin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
              }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
              $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
              }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
              $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
              }elseif(($type!="selec") AND ($admin!="selec")){
              $filter="type=\\"$type\\" AND admin>=\\"$admin\\"";
              }elseif(($type!="selec") AND ($pricemin!="")){
              $filter="type=\\"$type\\" AND price>=\\"$pricemin\\"";
              }elseif(($type!="selec") AND ($pricemax!="")){
              $filter="type=\\"$type\\" AND price>=\\"$pricemax\\"";
              }elseif(($type!="selec") AND ($city!="")){
              $filter="type=\\"$type\\" AND city>=\\"$city\\"";
              }elseif($type!="selec"){
              $filter="type=\\"$type\\"";
              }elseif($admin!="selec"){
              $filter="admin=\\"$a
          
          M Offline
          M Offline
          MacRaider4
          wrote on last edited by
          #8

          Well a comment or two would be pretty handy, as well as some better spacing (though I'm hoping you crammed it all together so it would fit better on the page?). That is one heck of a if statement though...

          P 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Looks like perfectly normal PHP to me. You mean PHP doesn't have to look like a child wrote in in Quick Basic? If true, I am amazed... :laugh:

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

            A Offline
            A Offline
            austin hamman
            wrote on last edited by
            #9

            that actually DOES look like something i wrote in qbasic when i was 10.

            1 Reply Last reply
            0
            • M MacRaider4

              Well a comment or two would be pretty handy, as well as some better spacing (though I'm hoping you crammed it all together so it would fit better on the page?). That is one heck of a if statement though...

              P Offline
              P Offline
              predicador
              wrote on last edited by
              #10

              No, i didn't.. Sad but true ;) I've translated names and wrote the few comments...

              ¿Eres tu John Wayne? ¿O soy yo?

              modified on Wednesday, June 8, 2011 12:59 PM

              M 1 Reply Last reply
              0
              • P predicador

                No, i didn't.. Sad but true ;) I've translated names and wrote the few comments...

                ¿Eres tu John Wayne? ¿O soy yo?

                modified on Wednesday, June 8, 2011 12:59 PM

                M Offline
                M Offline
                MacRaider4
                wrote on last edited by
                #11

                And I thought I was bad with comments... wow!

                A P 2 Replies Last reply
                0
                • M MacRaider4

                  And I thought I was bad with comments... wow!

                  A Offline
                  A Offline
                  austin hamman
                  wrote on last edited by
                  #12

                  comments is the least of this codes problems.

                  1 Reply Last reply
                  0
                  • M MacRaider4

                    And I thought I was bad with comments... wow!

                    P Offline
                    P Offline
                    predicador
                    wrote on last edited by
                    #13

                    D'oh! My Usual comments are not like this -_-'... Those were fast ones just for this post X| :laugh:

                    ¿Eres tu John Wayne? ¿O soy yo?

                    1 Reply Last reply
                    0
                    • P predicador

                      An ex-coworker asked me to help him with his first website (maybe last?). It's for a real estate agency. He was stuck trying to process the search form with some selects (price range, state size, zone location, bla, bla.. ) All the code is a fucking mess, but this piece of crap excels among all other:

                      $filter='';
                      $type=$_POST['type']; // Home, Flat...
                      $admin=$_POST['admin']; // Buy, Rent
                      $zone=$_POST['zone']; // Situation area
                      $m2=$_POST['m2']; // Size, stands for square meter
                      $price=$_POST['price'];

                          if(($type!="selec") AND ($admin!="selec") AND ($zone!="selec") AND ($m2!="selec") AND ($price!="selec")){
                          $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\" AND city=\\"$city\\"";
                          }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($pricemax!="")){
                          $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND price<=\\"$pricemax\\"";
                          }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemin!="") AND ($city!="")){
                          $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemin\\" AND city=\\"$city\\"";
                          }elseif(($type!="selec") AND ($admin!="selec") AND ($pricemax!="") AND ($city!="")){
                          $filter="type=\\"$type\\" AND admin=\\"$admin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
                          }elseif(($type!="selec") AND ($pricemin!="") AND ($pricemax!="") AND ($city!="")){
                          $filter="type=\\"$type\\" AND admin=\\"$pricemin\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
                          }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
                          $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
                          }elseif(($type!="selec") AND ($pricemax!="") AND ($city!="")){
                          $filter="type=\\"$type\\" AND price>=\\"$pricemax\\" AND city=\\"$city\\"";
                          }elseif(($type!="selec") AND ($admin!="selec")){
                          $filter="type=\\"$type\\" AND admin>=\\"$admin\\"";
                          }elseif(($type!="selec") AND ($pricemin!="")){
                          $filter="type=\\"$type\\" AND price>=\\"$pricemin\\"";
                          }elseif(($type!="selec") AND ($pricemax!="")){
                          $filter="type=\\"$type\\" AND price>=\\"$pricemax\\"";
                          }elseif(($type!="selec") AND ($city!="")){
                          $filter="type=\\"$type\\" AND city>=\\"$city\\"";
                          }elseif($type!="selec"){
                          $filter="type=\\"$type\\"";
                          }elseif($admin!="selec"){
                          $filter="admin=\\"$a
                      
                      H Offline
                      H Offline
                      H A Tanner
                      wrote on last edited by
                      #14

                      Wow this is very nice code. I´ll zeropad it to fixed line length copy an inversion of it to the front, rotate counterclockwise 90 degrees, apply a color index substitution. Et voila, we´ve got a sprite for a space invaders clone.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups