HDFilmMaker2112 Posted June 6, 2011 Share Posted June 6, 2011 if(isset($_GET['cat'])){ $cat=$_GET['cat']; $cat2=$_GET['cat']; $cat=str_replace("-"," ", $cat); if(isset($_GET['num_products']) && ctype_digit($_GET['num_products'])){ $num_products_per_page=(int)$_GET['num_products']; $_SESSION[$cat2]['num_products_per_page'] = $num_products_per_page; $num_products_per_page = stripslashes($num_products_per_page); $num_products_per_page = mysql_real_escape_string($num_products_per_page); } else{ $num_products_per_page="20"; } $num_products=' <form action="" method="GET"> <label>Display:</label> <select id="num_products" onchange="this.form.submit();" disabled="disabled"> <option value="8">8 Items per Page</option> <option value="12">12 Items per Page</option> <option value="16">16 Items per Page</option> <option value="20" selected="selected">20 Items per Page</option> <option value="24">24 Items per Page</option> <option value="32">32 Items per Page</option> <option value="40">40 Items per Page</option> <option value="48">48 Items per Page</option> </select> <noscript> <input type="submit" value="Go" /> </noscript> </form> '; if(isset($_GET['sort_by'])){ $sort_by_selected=$_GET['sort_by']; $_SESSION[$cat2]['sort_by_selected'] = $sort_by_selected; $sort_by_selected = stripslashes($sort_by_selected); $sort_by_selected = mysql_real_escape_string($sort_by_selected); if(isset($sort_by_selected)){ $sort_by_selected2=$sort_by_selected; if($sort_by_selected2=="product_price_hl"){ $sort_by_selected2="ABS(product_price) DESC"; } elseif($sort_by_selected2=="product_price_lh"){ $sort_by_selected2="ABS(product_price) ASC"; } } } else{ $sort_by_selected2="product_id"; } $sort_by=' <form action="store.php?cat='.$cat2.'" method="GET"> <label>Sort By:</label> <select id="sort_by" onchange="this.form.submit();"> <option value="relevance">Relevance</option> <option value="product_price_hl">Price: High to Low</option> <option value="product_price_lh">Price: Low to High</option> </select> <noscript> <input type="submit" value="Go" /> </noscript> </form> '; } else{ header("Location: ./index.php"); } For some reason the Sort By: form is redirecting to index.php... Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/ Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2011 Share Posted June 6, 2011 The only redirect in the script occurs if $_GET['cat'] isn't set, so that should indicate to you that $_GET['cat'] isn't set. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225732 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 But it is, because it's being set directly in the form action. http://ghosthuntersportal.com/store.php?cat=emf-meters Select another option from the Sort By: drop down, when it reloads it heads to index.php. It clearly defined in the form action as I viewed the page source code generated and it's there. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225734 Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2011 Share Posted June 6, 2011 No it isn't. Just look at the URL in the address bar after changing the sort option, and you can see that it is no longer there. Why do you have two separate sets of <form></form> tags in that script? Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225738 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 No it isn't. Just look at the URL in the address bar after changing the sort option, and you can see that it is no longer there. Why do you have two separate sets of <form></form> tags in that script? I can't see the URL in the address bar, because it takes off to index.php. And what do you mean two sets? One's for the Sort By form and the other for Display form. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225739 Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2011 Share Posted June 6, 2011 It almost ceratinly has to be something to do with the onchange= attribute in the <select> field. What happens if you remove it temporarily and use the submit button? Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225744 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 It almost ceratinly has to be something to do with the onchange= attribute in the <select> field. What happens if you remove it temporarily and use the submit button? same thing. redirects to index.php Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225745 Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2011 Share Posted June 6, 2011 Well, when any JS is involved, I'm inclined to defer to someone who knows it better than I do, which is what I need to do here . . . Sorry I can't take this one to a resolution, but Im sure someone here will be able to help out. EDIT: if it was me however, I'd get it working as desired without using any onchange= or JS, then add it after it was behaving the way I want. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225746 Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2011 Share Posted June 6, 2011 Surprisingly, the following link/answer is from a previous thread by the OP - http://www.phpfreaks.com/forums/index.php?topic=334223.msg1573995#msg1573995 Programming involves a huge amount of consistency and continuity. Something that worked before for a particular reason, will work the same way the next time you do it in the same situation. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225761 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 To be honest I forgot about that last thread. Anyway, I had tried the input hidden prior to starting this thread, and it didn't work. I just tried it again to be sure, and it's not working. That's the current active method being used here: http://www.ghosthuntersportal.com/store.php?cat=emf-meters Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225774 Share on other sites More sharing options...
KevinM1 Posted June 6, 2011 Share Posted June 6, 2011 That's because you have spelling errors. <inpuy type="hidden" id="cat" value="emf-meters" /> <orm action="" method="GET"> Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225847 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 Fixed the typos, still same result. I made the form submit to a separate page with this code: <?php echo $_GET['cat']; echo $_GET['sort_by']; ?> Result is a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225925 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 I got it to work when I added the name attribute to the select and input tags.... However, if I'm not mistaken the name attribute was deprecated in favor of the id attribute. So is this a error in the existing version of XHTML 1.1? It should be processing id as it had previously processed name. http://www.w3.org/TR/xhtml1/#h-4.10 Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225942 Share on other sites More sharing options...
KevinM1 Posted June 6, 2011 Share Posted June 6, 2011 I got it to work when I added the name attribute to the select and input tags.... However, if I'm not mistaken the name attribute was deprecated in favor of the id attribute. So is this a error in the existing version of XHTML 1.1? It should be processing id as it had previously processed name. http://www.w3.org/TR/xhtml1/#h-4.10 Re-read what it says. Only the name attribute for those particular elements has been deprecated. Note that input is not on the list. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225946 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 I read it as anything contained within <form></form> Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225947 Share on other sites More sharing options...
KevinM1 Posted June 6, 2011 Share Posted June 6, 2011 I read it as anything contained within <form></form> Then you read it incorrectly. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225949 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 Makes no sense why they wouldn't keep it uniform... deprecate for one thing, deprecate for everything. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225952 Share on other sites More sharing options...
KevinM1 Posted June 6, 2011 Share Posted June 6, 2011 Unless you plan on serving your pages as XML, there's no real point in writing XHTML anyway. XHTML is essentially dead. It never went anywhere, and I doubt there will ever be a new version of it. Stick with HTML 4.01, with some HTML 5 enhancements. It's far easier regarding doctype. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225954 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 6, 2011 Author Share Posted June 6, 2011 I use it because it requires stricter coding standards. And self-closing tags; technically they shouldn't be used in strictly HTML documents. Quote Link to comment https://forums.phpfreaks.com/topic/238521-form-submit-redirecting-unexpectedly/#findComment-1225958 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.