adam84 Posted August 14, 2007 Share Posted August 14, 2007 I was wondering if it will cause a problem if the user enters some text like: 'I got 100% on my test & 85% on my assignment. What did you get?' would the %, ? and & signs cause a problem with the data being sent? Is that a function that I should use to get around this...? Thanks Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 14, 2007 Share Posted August 14, 2007 You would want to use encodeURIComponent and/or encodeURI() Quote Link to comment Share on other sites More sharing options...
adam84 Posted August 14, 2007 Author Share Posted August 14, 2007 if i use the encodeURIComponent() function, will i have to do anything special with php to decode the data? Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 14, 2007 Share Posted August 14, 2007 yes urldecode(); Quote Link to comment Share on other sites More sharing options...
adam84 Posted August 14, 2007 Author Share Posted August 14, 2007 Still no like. This is what is going in: Used PHP to write JS echo "Function validate(){" //i took out all the validation tests and stuff echo "sendRequest( encodeURI('insertTitle.php?title='+title), 'result' );"; echo "}" I enter the text '100% Me? & You' and submit it the url being passed is: insertTitle.php?title=100%25%20Me?%20&20You my php file to process the data <? $title = $_GET['title']; echo urldecode($title); ?> result of this is: 100% Me? Quote Link to comment 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.