0

Maybe this is a basic question but I can't find anything that has convinced me either way. I am using ajax to send fields to be saved by a php page and it seems like it would be an easier solution to post them rather than mess around with url encoding

Kelly Larsen
  • 963
  • 1
  • 14
  • 30
  • 2
    It sounds like you're talking about PHP. I'm not really sure what you're asking, though. Could you give some more details about what you're trying to achieve, what you've tried so far, and what the results were? – Martin Atkins Mar 18 '13 at 00:46
  • 1
    yea sending to php, just edited question to clarify. been using $_GET so far and been having problems with &'s and ?'s in particular. I'm looking for something that I can safely send anything across, don't want to keep coming back as they find new ways to break the system... – Kelly Larsen Mar 18 '13 at 00:51
  • Special characters such as UTF-8 encoded data? Yes. Make sure your database driver is also configured for UTF-8 as well. – Julian H. Lam Mar 18 '13 at 00:52
  • yea nothing really fancy, no hieroglyphics or anything lol just what can be typed on a standard keyboard – Kelly Larsen Mar 18 '13 at 00:57
  • So really this isn't a question of GET vs. POST but a question of encoding; I guess right now you're trying to manually create a query string in your client but are struggling with handling the escaping necessary. Is that right? Are you asking about POST because the client library you're using is able to automatically do URL encoding for POST but not for GET? – Martin Atkins Mar 18 '13 at 00:57
  • It may clarify what you're trying to achieve if you can share some minimal example code from your client _and_ server and explain what shortcomings you see in it and what you'd like to improve. – Martin Atkins Mar 18 '13 at 01:01

2 Answers2

1

First of all, if you want to manipulate data in your model, you should always use POST and not GET. GET method philosophy is to be used in case of data retrieval.

Consider for example this: stackoverflow.com/questions/198462/, or even this: Wikipedia's thoughts on POST

And in answer to your question: Yes, you can. And if you have any problems with character encoding just make sure you're using the same encoding settings everywhere (webpage encoding, PHP mb_internal_encoding, MySQL encoding, etc.)

Community
  • 1
  • 1
Smuuf
  • 6,339
  • 3
  • 23
  • 35
0

you can use encode url which takes care of special characters.

Refer this

pravat
  • 465
  • 3
  • 11