Jump to content

Search the Community

Showing results for tags 'filter_input_array'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. GOAL: echo switch statement case which maps/matches to 'postType' PROBLEM: Regardless of what I try, the $_POST data seems to vanish, thus the switch statements default case is triggered and the form shows again instead of the intended/desired echo statement that I hope to show based on the postType contained within the $filter variable. I am working in PHP 5.4 A var_dump returns: array(2) { ["postType"]=> NULL ["myContent"]=> string(4) "dsfs" } I believe that I have both the form and the switch statement syntaxs/formatting correct. My problem, i think is somewhere in how the data is or isn't being passed to the switch via the filter_input_array(INPUT_POST, [...]) my humble code stub: error_reporting(E_ALL | E_STRICT); define('THIS_PAGE',basename($_SERVER['PHP_SELF'])); //test data //$_POST = [ 'postType' => 'myPlayby', 'myContent' => 'Anna King', ]; //build the array of data created by from for switch checks $filter = filter_input_array(INPUT_POST, [ 'postType' => [], 'myContent' => [], ]); var_dump($filter); echo "<br /><br />"; //$search = false; switch ($filter['postType']) { case 'myChar': echo "Character Check: " . $filter['myCharacter']; $search = $filter['myCharacter']; break; //test data ought to trigger myPlayby case showing 'Playby check: Anna King' here... frack case 'myPlayby': echo "Playbe Check: " . $filter['myPlayby']; $search = $filter['myPlayby']; break; case 'myFoobar': echo "Foo Check: " . $filter['myFooBar']; $search = $filter['myFooBar']; break; default: echo '<form type="submit" method="post" action="' . THIS_PAGE . '"; > <select name="postTypes"> <option default disable>-------------</option> <option value="myChar">Character</option> <option value="myPlayby">Playby</option> <option value="myFooBar">Foo</option> </select> <input type="text" value="" name="myContent"/> <input type="submit" name="submit" value="Submit"> </form>' ; break; } This is my first time working with filter_input_array to handle $_POST data, and after a day of trial, error, research and effort which include looking at Lynda.com, searching Google and reading what relevant posts I could find on StackOverflow, php.net, etc, I am flummoxed.test-switch-stack.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.