jacko_162 Posted November 2, 2012 Share Posted November 2, 2012 I have the following code on the following page; index.php?action=page;id=1 <p><span style="color:#9b6742;font-size:150%;font-weight:bold">Calculate Reward</span> <?php Print "<form action = '$_SERVER[php_SELF]' method = 'GET'> <input type='hidden' name='action' value ='page;id=1'> Total Courier Volume: <input type = 'text' name = 'volume' size='4'> (in m³) <br/> <input type='hidden' name='calc' value ='yes'> <input type = 'submit' name = 'Calculate'/> </form>"; if (($_GET['calc'] == "yes") && ($volume < '320000')) { $volume = $_GET['volume']; $reward = $volume*850; $iskReward = number_format($reward); print "<br><br><span style='color:#9b6742;font-size:150%;font-weight:bold'>Results</span><br><br>"; print "<form>The total Volume for contract is: <font color='#ff9900'><strong>$volume m³</strong></font><br> Total Reward to put on Contract is: <font color='#ff9900'><strong>$iskReward isk</strong></font>"; print " <input type = 'text' name = 'volume' value='$reward' size='8'> <--- Copy and paste reward</form><br><br><br><br>"; } else { //print "<h2>There has been an error</h2>"; } ?> </p> when i submit the form i get the following URL; index.php?action=page%3Bid%3D1&volume=850&calc=yes&Calculate=Submit+Query and what i need is: index.php?action=page;id=1&volume=850&calc=yes&Calculate=Submit+Query it looks like its not encoding the special characters ";" and "=" after "action=page" how can i fix this so it outputs what i need. Many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/270199-php-specialcharacters-in-url/ Share on other sites More sharing options...
Christian F. Posted November 2, 2012 Share Posted November 2, 2012 The URL you get is the correct one, as ; and = (can) have special meanings in an URI. To get them back to what you want, once you've received them, look up rawurldecode (). Though, that said, it should have been automatically converted back to their original characters. Whatever you do, however, you will not be able to override the browser's default behaviour of encoding those characters. If you need the ID as a separate parameter in the URL, then you'll need to create a separate input field for it. Quote Link to comment https://forums.phpfreaks.com/topic/270199-php-specialcharacters-in-url/#findComment-1389618 Share on other sites More sharing options...
PFMaBiSmAd Posted November 2, 2012 Share Posted November 2, 2012 (edited) A) It's the browser that is doing the urlencoding and there's nothing you can do to stop it. B) The actual $_GET data available on that page has been urldecoded and is correct. Edited November 2, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/270199-php-specialcharacters-in-url/#findComment-1389619 Share on other sites More sharing options...
jacko_162 Posted November 2, 2012 Author Share Posted November 2, 2012 (edited) problem is its an already established SMF (FORUM) mod that allows me to add "pages" with php code embedded. the url for the first page is already; forum/index.php?action=page;id=1 all i need is a calculator so a user can input a volume (for example 500) and i need to calculate a reward for the 500 volume base on the following maths: $volume x 850 is there another way i can do this without using a form and the GET method? for example ajax or JS ? Edited November 2, 2012 by jacko_162 Quote Link to comment https://forums.phpfreaks.com/topic/270199-php-specialcharacters-in-url/#findComment-1389623 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.