Jump to content

Php Specialcharacters In Url


jacko_162

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by jacko_162
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.