aytac Posted January 5, 2011 Share Posted January 5, 2011 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. 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 More sharing options...
unlishema.wolf Posted January 6, 2011 Share Posted January 6, 2011 when you click on the button lotto it takes you to the same page but with ?page=lotto added at the end of it? Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1155536 Share on other sites More sharing options...
aytac Posted January 6, 2011 Author Share Posted January 6, 2011 yes but after i click on "OK" ?page=lotto disappear ... Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1155607 Share on other sites More sharing options...
unlishema.wolf Posted January 6, 2011 Share Posted January 6, 2011 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; ?> Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1155796 Share on other sites More sharing options...
aytac Posted January 6, 2011 Author Share Posted January 6, 2011 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 https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1155881 Share on other sites More sharing options...
aytac Posted January 7, 2011 Author Share Posted January 7, 2011 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 https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156208 Share on other sites More sharing options...
BlueSkyIS Posted January 7, 2011 Share Posted January 7, 2011 It does give me a syntax error ... which is????????????????????????????? Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156240 Share on other sites More sharing options...
aytac Posted January 7, 2011 Author Share Posted January 7, 2011 Parse error: syntax error, unexpected T_ECHO in C:\xampp\htdocs\ictproject\lotto\index.php on line 5 Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156260 Share on other sites More sharing options...
BlueSkyIS Posted January 7, 2011 Share Posted January 7, 2011 getting closer... which line is line 5, and what are the 4 lines before it? Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156268 Share on other sites More sharing options...
aytac Posted January 7, 2011 Author Share Posted January 7, 2011 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 https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156275 Share on other sites More sharing options...
BlueSkyIS Posted January 7, 2011 Share Posted January 7, 2011 ah yes, you can't append an echo to an echo, and you can't put a semi-colon in mid-command. echo '<center><form action="'. $strPage .'" method="POST"><select name="test">'; also: where is $strPage coming from? Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156297 Share on other sites More sharing options...
aytac Posted January 7, 2011 Author Share Posted January 7, 2011 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 ! echo '<center><form action="'.$strPage = $_POST['page'].'" method="POST"><select name="test">'; Thanks guys for helping me Link to comment https://forums.phpfreaks.com/topic/223513-error-after-php-form/#findComment-1156334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.