How to stop form converting special chars?? |
[eluser]umbungo[/eluser]
1. I have a form using 'get' which has some values which include characters such as ( ) , How can I keep these as ( ) , and not eg. % 2C (no space), in the URL when the form is submitted?? 2. On a similar note, when I add items which have a name including eg ( ) to my cart using $this->cart->insert($array) this does not work. Can i make this work and keep brackets?
[eluser]andyy[/eluser]
1. Try using htmlentities() and html_entity_decode(): php.net: htmlentities() php.net: html_entity_decode() 2. Not too sure about the cart issue with brackets, it should insert no problem. Can you post the code you are working with please?
[eluser]InsiteFX[/eluser]
This has been answered before on the forums here, you will need to search for it. InsiteFX
[eluser]umbungo[/eluser]
1. I don't see how i could use this. The text is in 'regular' form when it is submitted. eg.... Code: <form method="get" action="/somewhere"><input type="checkbox" name="name" value="this,that"> <-submit-></form> 2. The relevant code is just an array(id=>$id, name=>$name, 3=>$c) etc followed by $this->cart->insert($array). Where $name contains a bracket, the item isn't added to the cart. Otherwise they add fine. PS: i did search so either i was using the wrong terms or the information wasn't what i needed.
[eluser]WanWizard[/eluser]
By default, a name may only contain alpha-numeric, dashes, underscores, colons or periods. Similar rules exist for the id field. You can alter them via $this->cart->product_id_rules and $this->cart->product_name_rules. Both should be a valid regex. This should be documented, but isn't. Next time you have this you might want to look at the code, this would have been obvious right away.
[eluser]umbungo[/eluser]
Thanks WanWizard, #2 sorted. I have tended not to look at the code because I have tried to keep it at 'stock' settings as it were. I wouldn't have expected it to be quite so obvious (second line of code) either! And yes, it really should be documented, product names with slashes or brackets can't be that uncommon. So can anyone help me out with #1?
[eluser]umbungo[/eluser]
Regarding #1; failing any proper solution what i have done is to implement a redirect on the page which the 'get' sends to. Code: if(strpos($_SERVER['QUERY_STRING'], '%')!=false){
[eluser]WanWizard[/eluser]
As to your #2: Your using a get, so any fields in the form will be part of the query string when you submit the form. So make sure the values posted are valid for use in a URI. This has been mentioned in the first reply. If not possible, use a post form, and if you insist on a query string, process the post, craft a correct URI including the query string, and redirect to it. |
Welcome Guest, Not a member yet? Register Sign In |