Jump to content

error after php form


aytac

Recommended Posts

Hey ,

 

I've made a website with 2 menubuttons(lotto , euromillions).

When I click on lotto -> I must choose a value of a dropdownlist and click on OK.

Now when I click on "OK" after ive picked a value -> it says that the pagename is empty and gives an error.

 

To fill the pagename I've added an ELSE function, but it does fix only 1 of the 2 forms which is not the point.

 

Maybe I can fix this by using menuarray to make an IF-ELSE code for the 2 menu. :confused:

 

Can someone give me an idea to solve this ? :-[

 

Index page -> to write the pagename which selects the included file.

    if (array_key_exists($_GET["page"], $arrMenuItems)){
        $strPage = $_GET["page"];
    }else{
        //$strPage = "lotto";
        //$strPage = "euromillions";
    }

 

MenuArray -> links to pages

$arrMenuItems = array(
     "lotto" => array(
            'menuitem'=>'lotto' ,
            'page_id' => '?page=lotto',
            'page_name' =>'lotto',
            'page_content'=> 'lotto/index.php',
            'page_css'=>'lotto.css',

           ),
     "euromillions" => array(
            'menuitem'=>'euromillions' ,
            'page_id' => '?page=euromillions',
            'page_name' =>'euromillions',
            'page_content'=> 'euromillions/index.php',
            'page_css' => 'euromillions.css',
           ),
);

 

Link to comment
https://forums.phpfreaks.com/topic/223513-error-after-php-form/
Share on other sites

        echo '<center><form action="'.echo $strPage.'" method="POST"><select name="test">';
        echo '<option selected>Kies aantal rooster</option></center>';
        echo '<option value="1">2 roosters</option>';
        echo '<option value="2">4 roosters</option>';
        echo '<option value="3">6 roosters</option>';
        echo '<option value="4">8 roosters</option>';
        echo '<option value="5">10 roosters</option>';
        echo '<option value="6">12 roosters</option>';
        echo '</select>';
        echo '<input type="checkbox" name="zelfkeuze">Random aan';
        echo '<button type="submit" name="knop" value="instok">OK</button>';
        echo '</form></td></tr>';

 

Did you mean this ?

But I've a problem with adding this to action. It does give me a syntax error ...

This is my  code.

5th line is form action etc

 

<?php
  echo '<table>';
    echo '<tr><td colspan="3">';
    /* Keuzelijst tonen */
        echo '<center><form action="'.echo $strPage;.'" method="POST"><select name="test">';
        echo '<option selected>Kies aantal rooster</option></center>';
        echo '<option value="1">2 roosters</option>';
        echo '<option value="2">4 roosters</option>';
        echo '<option value="3">6 roosters</option>';
        echo '<option value="4">8 roosters</option>';
        echo '<option value="5">10 roosters</option>';
        echo '<option value="6">12 roosters</option>';
        echo '</select>';
        echo '<input type="checkbox" name="zelfkeuze">Random aan';
        echo '<button type="submit" name="knop" value="instok">OK</button>';
        echo '</form></td></tr>';
    echo '<table>';
     echo $strPage;
    $strPage = $_GET['page'];
    $aantalrooster = $_POST['test'];
    $random = $_POST['zelfkeuze'];
    include ('klasse_lotto.php');
    $objLotto = new klasse_lotto($aantalrooster, $random);
    $objLotto->tabel_tonen();
?>

 

 

have it put the page value back in when you hit ok. like this

 

<?php $page = $_GET['page']; ?>

 

then just add this in the ok buttons html at the end of the url it goes to.

 

<?php echo $page; ?>

 

Thanks , first one helped me ! :D

 

echo '<center><form action="'.$strPage = $_POST['page'].'" method="POST"><select name="test">';

 

Thanks guys for helping me  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.