Mistake Posted October 25, 2009 Share Posted October 25, 2009 Hello, i need help by making a script! I need to write a file with option box, so a dropdown menu with 10 or more options, and when i select one option a button to save this option to a php variable in one file! So then i can call up this variable in another file! Please help me! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/178888-option-box-to-change-variable/ Share on other sites More sharing options...
Alex Posted October 25, 2009 Share Posted October 25, 2009 You're gonna want to look into sessions If you need an example just ask. Quote Link to comment https://forums.phpfreaks.com/topic/178888-option-box-to-change-variable/#findComment-943745 Share on other sites More sharing options...
Mistake Posted October 25, 2009 Author Share Posted October 25, 2009 An example would be great! And i will start now on my own, but i think an example is better! Quote Link to comment https://forums.phpfreaks.com/topic/178888-option-box-to-change-variable/#findComment-943960 Share on other sites More sharing options...
Glen Posted October 25, 2009 Share Posted October 25, 2009 This should work I think: <?php session_start(); echo '<form action = "" method = "POST"'; echo'<select name="dropdown"> <option value="store" >Option 1</option> <option value="values" >Option 2</option> <option value="here" >Option 3</option> </select>'; echo '<input type = "submit" name = "submit" value = "Get Value!" </form>'; if(isset($_POST['submit'])) { $value = $_POST['dropdown']; $_SESSION['value'] = $value; echo $_SESSION['value']; } ?> To value is stored in $_SESSION['value'] to call the value in another page remember to use session_start(); at the very top. -Glen Quote Link to comment https://forums.phpfreaks.com/topic/178888-option-box-to-change-variable/#findComment-943965 Share on other sites More sharing options...
Mistake Posted October 25, 2009 Author Share Posted October 25, 2009 Thank you for your exaple I tried to make what i need with your example! But i could not get what i will! I have a file on my website wich shows the current dj on radio, listeners etc. You can visit it on this adress http://choko-radio.com/eter/radio_stats.php You will se the section DJ Online, I change the name of the dj manually editing the variable in the file! But i need to change the name of the dj trough another file with the options box feature! Please help! Quote Link to comment https://forums.phpfreaks.com/topic/178888-option-box-to-change-variable/#findComment-944120 Share on other sites More sharing options...
Mistake Posted October 25, 2009 Author Share Posted October 25, 2009 Thank you for you help, i coded around and i get this to work with this script: <?php echo '<form action = "" method = "POST"'; echo'<select name="dropdown"> <option value="DJ MisTake" >DJ MisTake</option> <option value="kenox" >kenox</option> <option value="TiruRiru" >TiruRiru</option> </select>'; echo '<input type = "submit" name = "submit" value = "Promjeni DJ-a!" </form>'; if(isset($_POST['submit'])) { $value = $_POST['dropdown']; $string = '<?php $djpusta = "'. $_POST['dropdown']. '"; ?>'; $fp = fopen("config_dj.php", "w"); fwrite($fp, $string); fclose($fp); } ?> Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/178888-option-box-to-change-variable/#findComment-944314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.