# $\_POST in a switch does sometimes work

**URL:** <https://forum.kirupa.com/t/-post-in-a-switch-does-sometimes-work/321132>\
**Category:** programming\
**Created:** [April 11, 2011, 6:28pm UTC](https://forum.kirupa.com/t/-post-in-a-switch-does-sometimes-work/321132 "2011-04-11T18:28:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Badr](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Badr](https://forum.kirupa.com/u/Badr)\
**Post date:** [April 11, 2011, 6:28pm UTC](https://forum.kirupa.com/t/-post-in-a-switch-does-sometimes-work/321132/1 "2011-04-11T18:28:19Z")

</div>

Hi,

Ive got a problem since friday ive tried many things to solve it.  
Perhaps some can help me with it  
What the code does:

case ‘toon\_prijs’: gets the info of a product for a form for changing.

case ‘wijzig\_prijs\_metalstud’: Put the inserted information in the database.

So whats to problem?  
The $\_POST[id] in ‘‘case wijzig\_prijs\_metalstud’’ doesnt work anymore.  
But the $\_GET[id] ‘case toon\_prijs’ does work.

Also it give a: ‘ **Notice** : Undefined index: id’ or ‘id’

Ive tried allot but nothing works.

Ive already tested with:

```php
if{isset($_GET[id]) != ""){
echo "its full";
}else{
echo "its empty";
}

```

In ‘‘wijzig\_prijs\_metalstud’’ its empty.  
But in ‘toon\_prijs’ its full…

If i replace $\_POST[id] with a number like ‘25’ it does work.

PART OF THE CODE

```php

case 'toon_prijs':
        
        
        $rsPlafondPlaatPrijs=("SELECT * FROM metalstud_prijzen WHERE id='$_GET[id]'");
        $queryPrijsPlafondplaat=mysql_query($rsPlafondPlaatPrijs) or die(mysql_error());

        if($result_prijs=mysql_fetch_array($queryPrijsPlafondplaat)) {
            $id="<input type='hidden' name='id' value='$result_prijs[id]' />";
            
            $type=$result_prijs['type'];
            $lengte=$result_prijs['lengte'];
            $breedte=$result_prijs['breedte'];
            
            $prijs=$result_prijs['prijs'];
            $prijs_notatie=$result_prijs['prijs_notatie'];
            
            ## afbeelding weergeven ##
            
            if($result_prijs['afbeelding']!="geenafbeelding.jpg") {
                $file_field="<img src='../producten/".$result_prijs['afbeelding']."' border='1' width='100'><br><a href='index.php?pagina=metalstud_prijzen&product=$_GET[product]&id_product=$_GET[id_product]&id=$_GET[id]&aktie=wis_afbeelding' class='link'>wis afbeelding</a><input type='hidden' name='afbeelding' value='$result_prijs[afbeelding]' />";
                                                                                                                          //index.php?pagina=metalstud_prijzen&product=plafondplaten&id_product=1&id=3&aktie=toon_prijs
            } else {
                $file_field="<input type='file' name='afbeelding' id='afbeelding' />";
            }

        }
        $button="<input type='submit' name='button' id='button' value='wijzig prijs' />"; $aktie="wijzig_prijs_metalstud";
        
        break;

        ## prijs plafond plaat wijzigen ##
        
        case 'wijzig_prijs_metalstud':
        
        $ruPlafondPlaatPrijs=("UPDATE metalstud_prijzen SET afbeelding='$afbeelding', type='$_POST[r_type]', lengte='$_POST[r_lengte]', breedte='$_POST[r_breedte]', prijs='$_POST[r_prijs]', prijs_notatie='$_POST[r_prijs_notatie]' WHERE id='$_POST[id]' ");
        mysql_query($ruPlafondPlaatPrijs) or die (mysql_error());
            
        $button="<input type='submit' name='button' id='button' value='voeg prijs toe' />"; $aktie="prijs_metalstud_toevoegen"; $file_field="<input type='file' name='afbeelding' id='afbeelding' />";
        
        $melding="<p class='melding'>De prijs is gewijzigd.</p>";

        break;
        
        default: $button="<input type='submit' name='button' id='button' value='voeg prijs toe' />"; $aktie="prijs_metalstud_toevoegen"; $file_field="<input type='file' name='afbeelding' id='afbeelding' />";
            

```

Thanks !
