Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP form variable

I am passing the following variable from a php form:
%2F%3E%0D%0A%C2%A3500

The result is as follows:
£550

I need to get rid of the preceeding Â

The GET variable is as follows:
$invdetails = $_GET['invDetails'];

Can I use the str_replace(' ',' ',' ') to do this?
If so, how
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doctorbill

ASKER

Can you tell me how to see (echo)  the result of a urldecode please
Sure:

echo urldecode("%2F%3E%0D%0A%C2%A3500");

Open in new window

I am passing the following variable from a php form:
%2F%3E%0D%0A%C2%A3500

how do you pass that variable?

show your js/jQuery/php code...
you should have some bad code there, not on the request part...
This is the form:

<form id="formSend" name="formSend" method="get" action="InvoiceSend/email_invoice.php">
              <table width="100" border="0" cellpadding="0">
                <tr>
                     <td width="15"><input name="emailAddress" type="text" class="generate_invoice" id="emailAddress" /><br />
<textarea style="font-size:10px; font-style: italic; color: #999999" name="comment" rows="2" cols="30">comments</textarea></td>
<input type="hidden" name="invPath" id="hiddenField" value="<?php echo "../" . $row_Invoices['Path']; ?>" />
<input type="hidden" name="invDetails" id="hiddenField" value="<?php echo "<br />" . $row_Invoices['Details']; ?>" />
<input type="hidden" name="invTotal" id="hiddenField" value="<?php echo $row_Invoices['Total']; ?>" />
<input type="hidden" name="invPaypal" id="hiddenField" value="<?php echo "http://ticktockit.dyndns.biz:888/ticktock_int/results_invoices_IDSel_Client.php?invNo=" . $row_Invoices['InvoiceNo']; ?>" />
                  <td width="15" valign="top"><label>
                    <input name="button" type="submit" class="generate_invoice" id="button" value="Send" />
                  </label></td>

                </tr>
              </table>
              </form>

The line which is causing the  issue is as follows:
<input type="hidden" name="invDetails" id="hiddenField" value="<?php echo "<br />" . $row_Invoices['Details']; ?>" />

The field in the database is latin1_swedish_ci ( I created this a long time ago so I probably used the incorrect encoding)
Can I change this to utf8 without causing any data loss?
Maybe. First off, try changing the encoding of the page. Add this to the top of your page (in the <head> element):

<meta charset="utf-8">

Also try removing that <br /> from the input.

Finally, check the source of your page to see what is actually being pulled in from $row_Invoices['Details'];

Somewhere, you're getting an extra closing bracket, so that needs sorting out one way or the other.
<input type="hidden" name="invDetails" id="hiddenField" value="<?php echo " <br />" . $row_Invoices['Details']; ?>" />

Open in new window


get rid of " <br />" here

<input type="hidden" name="invDetails" id="hiddenField" value="<?php echo $row_Invoices['Details']; ?>" />

Open in new window


and hopefully it fixes everything and you dont need to do anything else...
if above does not work, post a sample, rendered html from browser, right click, view source, copy paste form html here...

also, you have issue here as well...

<input type="hidden" name="invPath" id="hiddenField" value="<?php echo " ../ " . $row_Invoices['Path']; ?>" />

Open in new window


>>>> get rid of extra space before and after "../"

<input type="hidden" name="invPath" id="hiddenField" value="<?php echo "../" . $row_Invoices['Path']; ?>" />

Open in new window

I see some more issues with your form variables

     <input type="hidden" name="invPath" id="hiddenField" value="<?php echo " ../ " . $row_Invoices['Path']; ?>" />
      <input type="hidden" name="invDetails" id="hiddenField" value="<?php echo " <br />" . $row_Invoices['Details']; ?>" />
      <input type="hidden" name="invTotal" id="hiddenField" value="<?php echo $row_Invoices['Total']; ?>" />
      <input type="hidden" name="invPaypal" id="hiddenField" value="<?php echo " http://ticktockit.dyndns.biz:888/ticktock_int/results_invoices_IDSel_Client.php?invNo=" . $row_Invoices['InvoiceNo']; ?>" />

each one should have a unique ID!!!
for 1st hidden field, use "hfinvPath" or just use same values as name, ie "invPath" ...
similarly do the same thing for all others...
try with utf8_encode / utf8_decode
so how do I use the utf8_encode with the variable
<input type="hidden" name="invDetails" id="hiddenField" value="<?php echo utf8_encode($row_Invoices['Details']); ?>" />

$invdetails = utf8_decode($_GET['invDetails']);
your issue looks like you put special characters inside hidden variable

did you try ID: 42271464???

you dont need to change anything, just remove  " <br />" from invDetails
(+ all other issues mentioned in my next posts, but they are not related to current issue that you have right now)
Will let you know
We've been telling you it's the probably the <br /> right from the start :) Would have thought that was the first thing you tried!
I Tried removing the <br /> - no difference
I Tried removing the <br /> - no difference

ok, after all changes, what is your current code
what is nor working now
and what is eror message now...
Thanks all