Jump to content

Passing a string (GET method) with quotations


ze1d

Recommended Posts

Hi all,Whenever I pass a string (using form) with single quotation or double like "car" or 'car' and try to show it on the other page it replaces each quotation with \ like this \car\how can i disable this and make it look normal??Thanks very much,zeid

Link to comment
Share on other sites

You can use the get_magic_quotes_gpc function to test if the config option is set to do that, and if so you can use the stripslashes function to remove the slashes. Check the examples on this page, but you'll be using stripslashes instead of addslashes.http://www.php.net/manual/en/function.get-...-quotes-gpc.php

Link to comment
Share on other sites

If you use $_GET as a value in a textbox, you will need to use htmlentities or htmlspecialchars.Here is what your code would look like if you didn't use these functions:

<input type="text" value=""car">

As you can see it closes the value when using ". The functions prevent this from happening by replacing characters in HTML (such as <, >, &, ", and ' [you will need to use ENT_QUOTES for the second parameter in the functions for ' to be replaced]) with their entities (<, >, &, ", ').You enter "car" for the $_GET['q'] value. Here is what it will look like in the HTML:

<input type="text" value=""car"">

You can see that there is no way of getting out of the value by using " when it's being replaced.http://us2.php.net/manual/en/function.htmlentities.phphttp://us2.php.net/manual/en/function.htmlspecialchars.php

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...