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
Share on other sites

Where do I need to add this ?

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

 

 

and 2nd thing : isn't that just printing it out on the website ?

 

btw I ve uploaded my project , so you can have better look at it

 

[attachment deleted by admin]

Link to comment
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 ...

Link to comment
Share on other sites

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();
?>

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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