handling commas

D

darren

Hello,

I am posting a html form to a php processing page, which produces a csv file
from the form data. However if the user inputs a comma then it screws up my
data.

So i'd like to know how to strip my data of commas before submitting to the
php processor.

Or maybe not strip the commas but handle them better.

many thanks

darren
 
E

Evertjan.

darren wrote on 08 mrt 2005 in comp.lang.javascript:
I am posting a html form to a php processing page, which produces a
csv file from the form data. However if the user inputs a comma then
it screws up my data.

So i'd like to know how to strip my data of commas before submitting
to the php processor.

Or maybe not strip the commas but handle them better.

<form
onsubmit='this.a.value=this.a.value.replace(/,/g,"")'>
<input name=a>
</form>
 
L

Lee

darren said:
Hello,

I am posting a html form to a php processing page, which produces a csv file
from the form data. However if the user inputs a comma then it screws up my
data.

So i'd like to know how to strip my data of commas before submitting to the
php processor.

Or maybe not strip the commas but handle them better.

Any sort of critical data handling MUST be done on the server
in your PHP code. You don't know that the user has Javascript
enabled, and a malicious user could easily bypass your processing.
 
M

Matt Kruse

darren said:
I am posting a html form to a php processing page, which produces a
csv file from the form data. However if the user inputs a comma then
it screws up my data.

Instead, create a CSV file using the correct format. Quote your values, and
commas in the values won't matter. Then escape quotes within the values to
be "" in the PHP side. Then you're bullet-proof.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top