Tarayıcıda bir form ve ekran (PHP) den tut verileri

0 Cevap php

I am trying to grab data a user selected from a drop down menu. User either selects view all, option 1, option 2, or option 3. I have a function called getUserCategory that stores the user choice in a variable called $category. I tried getting the value of the function by doing:

return $category getUserCategory işlev içinde

ve sonra yazılı:

$catChoice = getUserCategory();

Ben bir yankı açıklama yapmaya çalıştığımızda tarayıcıda $ catChoice görüntülemek mümkün değildi.

echo $catChoice;

Ben de işlev içinde yankılanan çalıştı

echo $cateogry; 

ama yine de, tarayıcıda değerini görüntülemek mümkün değildir.

Form

    <form action="register_script.php" name="frm" method="post">
        <select name="category" id="category">
            <option value="viewall">View All</option>
            <option value="option1">option1</option>
            <option value="option2">option2</option>
            <option value="option3">Sandals</option>
       </select>

      <input type="submit" value="Go" />  

PHP

 //call function getUserCategory ---------------------------------------------------        
        getUserCategory();
        //$catChoice = getUserCategory();

//function getUserCategory --------------------------------------------------------     
        function getUserCategory() {
            echo "<br/>" . "In the getUserCategory function Msg 1" . "<br/>";
            $category = $_POST["category"]; 
            //return $category;
            echo $cateogry . "<br/>";
            echo "In the getUserCategory function Msg 2";
        }

0 Cevap