godsent Posted December 16, 2008 Share Posted December 16, 2008 I'm trying to make code that redirects to selected page from form list. This code not working correctly because gets "cat" before its even selected so its basically 1. <form action="?id=<?php print $_POST['cat']; ?>" method="post"> <select name="cat"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> <option value="4">four</option> <option value="5">five</option> </select> <input type="submit" name="Submit" value="Accept" /> </form> i don't really know how this form should be made. If you know please help Link to comment https://forums.phpfreaks.com/topic/137196-formlist-help/ Share on other sites More sharing options...
gevans Posted December 16, 2008 Share Posted December 16, 2008 Keep your form as the following; <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post"> <select name="cat"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> <option value="4">four</option> <option value="5">five</option> </select> <input type="submit" name="Submit" value="Accept" /> </form> #$_SERVER['PHP_SELF'] used to send the request to the current page and on the receiving page (using the script above it'd be the same page) something like the following <?php $cat = (is_numeric($_POST['cat']))? $_POST['cat'] : 0; $id = $cat; ?> Link to comment https://forums.phpfreaks.com/topic/137196-formlist-help/#findComment-716684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.