pratuljena Posted June 25, 2013 Share Posted June 25, 2013 Hello all, I am very new the to php. I need help on the following problem. I have a page say reportview.php having a combobox with three options like :platform, playlist, build And I have another three pages like reportbyplatform.php, reportbyplaylists.php and reportbybuild.php. Now based on the option I have selected I want to call the respective php. for example if I select platform from the combo box then my action should be reportbyplatform.php, if I select playlist from the combo box the action should be reportbyplaylists.php and so on. code snippet <html><body><h1> <p align="Justify"> <font color="blue"> JST Automation Report </font> </h1><form action="?">Show report by : <select id='viewType'> <option value="platform">platform</option> <option value="playlists">Playlists</option> </select> <br> <br> <br> <input type="submit" value=" Show Report "></form> Please help me on this Thanks Pratul Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 25, 2013 Share Posted June 25, 2013 When you build the first page, set action to the script doing that build. Then when the page is submitted to that script, capture the checkbox choice. If you have one, then do this: if ($checkbox_value == "platform") $url='platform.php'; if ($checkbox_value == 'playlist') $url = 'playlist.php'; header("Location: $url"); The last line will take you to your script. Quote Link to comment Share on other sites More sharing options...
Strider64 Posted June 25, 2013 Share Posted June 25, 2013 (edited) reportview.php <?php if (isset($_POST['submit']) && $_POST['submit'] == 'submit') { $redirectToPage = htmlspecialchars($_POST['report']); //Sanitize user's input header("Location: " . $redirectToPage); exit; } ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Reports Tutorial</title> <style> #basic { background-color: #efefef; border: 2px solid #000; color: red; font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; font-size: 16px; font-weight: bold; padding: 10px; } #basic option { background-color: #666; color: #fff; padding: 5px 5px 0; } #basic:hover, #basic option:hover { background: #ccc; } </style> </head> <body> <form action="reportview.php" method="post"> <select id="basic" name="report"> <option selected="selected" value="reportbyplatform.php">Please select your report:</option> <option value="reportbyplatform.php">Platform</option> <option value="reportbyplaylists.php">Playlist</option> <option value="reportbybuild.php">Build</option> </select> <input type="submit" name="submit" value="submit"> </form> </body> </html> Edited June 25, 2013 by Strider64 Quote Link to comment 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.