darkminos Posted June 27, 2012 Share Posted June 27, 2012 Sooo... every time I try to submit a form, the url is being encoded .php?res_per_page=25&sort_by=Relevance&search_items%3Dsomething%26search_dropdown%3DAll= echo "<form method=get"; echo "?"; echo ">"; echo "Display items"; echo "<select name=res_per_page>"; ... echo "</select>"; echo "Sort by"; echo "<select name=sort_by>"; ... echo " </select>"; echo " <input type=hidden name=$replaced>"; echo " <input type=submit value=GO class=searchbutton>"; echo " </form>"; Even when trying to decode it before submitting with the following code... $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'); $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]"); $replaced = str_replace($entities, $replacements, $temp); Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/ Share on other sites More sharing options...
Barand Posted June 27, 2012 Share Posted June 27, 2012 Thank you for your comment. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357566 Share on other sites More sharing options...
PaulRyan Posted June 27, 2012 Share Posted June 27, 2012 http://www.php.net/manual/en/function.urldecode.php Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357568 Share on other sites More sharing options...
darkminos Posted June 28, 2012 Author Share Posted June 28, 2012 Rather then decoding the url I am looking to stop encoding it in the first place Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357639 Share on other sites More sharing options...
darkminos Posted June 28, 2012 Author Share Posted June 28, 2012 I mean, is there a way for the browser to show = rather than %3D?? there is too much happening within the script for me to change all of the variables to urlencode() Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357786 Share on other sites More sharing options...
xyph Posted June 28, 2012 Share Posted June 28, 2012 I mean, is there a way for the browser to show = rather than %3D?? there is too much happening within the script for me to change all of the variables to urlencode() There's a reason it's encoded... you don't want to change this behaviour. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357787 Share on other sites More sharing options...
DavidAM Posted June 28, 2012 Share Posted June 28, 2012 Certain characters have special meaning in the URL, so the browser must encode them before sending them. PHP realizes this, and will (should) decode them before you see them in $_GET. Are you seeing a problem processing this data in your PHP script? If so, describe the problem you are having and we can probably help. Are you just looking for a way to make the url look "pretty"? If so, you need to look into the (Apache) mod_rewrite module. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357791 Share on other sites More sharing options...
darkminos Posted June 28, 2012 Author Share Posted June 28, 2012 Right, sorry I should have explained better. Looks have nothing to do with my problem. the last time I done php is 10 years ago and see some differences, like the variable carried over in the URL is not always accessible by just calling it $some_variable, now I have to $_GET['some_variable']... not always however. Now, when I have some_variable=something in the URL I can get it no problem with $some_variable, however when I have some_variable%3Dsomething I can't get it. I hope this makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357801 Share on other sites More sharing options...
xyph Posted June 28, 2012 Share Posted June 28, 2012 I've never had PHP automatically urlencode() values for me. I'm not sure how/why that %3D is being generated. You'd have to show us the code that generates your anchor tags. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357816 Share on other sites More sharing options...
Barand Posted June 28, 2012 Share Posted June 28, 2012 I suggest you read up on register_globals and why it was deprecated 10 years ago as a security hole. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357817 Share on other sites More sharing options...
Barand Posted June 28, 2012 Share Posted June 28, 2012 I've never had PHP automatically urlencode() values for me. You have whenever you submitted a form with method = GET, but not when you build a querystring yourself Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357819 Share on other sites More sharing options...
xyph Posted June 28, 2012 Share Posted June 28, 2012 I've never had PHP automatically urlencode() values for me. You have whenever you submitted a form with method = GET, but not when you build a querystring yourself I'm not sure what you mean? Isn't submitting a form a client-side action? GET/POST is decided and implemented client-side? Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357820 Share on other sites More sharing options...
darkminos Posted June 28, 2012 Author Share Posted June 28, 2012 Ok... I can't believe how simple the solution was... echo "<input type=hidden name=search value=".$_GET['search'].">"; I was trying to send the actual variable in the name field... It was good to be educated on some of the changes done since PHP3 Thank you for the help! Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357824 Share on other sites More sharing options...
Barand Posted June 28, 2012 Share Posted June 28, 2012 @xyph <?php echo <<< html <form method='get'> <input type='text' name='text1' value='a b c' /> <br /><br /> <input type='submit' value='Submit' name='btnSub' /> </form> html; ?> What I meant was this. When the above form is submitted, the query string will be ?text1=a+b+c&btnSub=Submit ie the text field value is automatically urlencoded. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357828 Share on other sites More sharing options...
xyph Posted June 28, 2012 Share Posted June 28, 2012 @xyph <?php echo <<< html <form method='get'> <input type='text' name='text1' value='a b c' /> <br /><br /> <input type='submit' value='Submit' name='btnSub' /> </form> html; ?> What I meant was this. When the above form is submitted, the query string will be ?text1=a+b+c&btnSub=Submit ie the text field value is automatically urlencoded. The encoding is done client-side though, right? I still have no idea what the OP is really trying to accomplish, so maybe that's why I'm confused. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357837 Share on other sites More sharing options...
Barand Posted June 28, 2012 Share Posted June 28, 2012 I still have no idea what the OP is really trying to accomplish, so maybe that's why I'm confused. you and me. Quote Link to comment https://forums.phpfreaks.com/topic/264902-url-encoding-when-submitting-a-form/#findComment-1357838 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.