Skip to content
Advertisement

PHP form that generates CSV – removing commas from the comments field

I have a dual purpose HTML form which return both email and a CSV file to my server.

On my HTML form I have a field titled ‘Notes’ which is a text area. I need to prevent the CSV output file from seeing any commas a user may enter into the text area.

This avoids the ‘Notes’ area of the CSV output file from spanning multiple cells accidentally.

Ideally I would like a code that prevents both commas and returns, but I’ll settle for commas. Please be sure to indicate WHERE your solution should go in my code below. Im newer to PHP and thus don’t understand order.

Here is my PHP code:

JavaScript

Advertisement

Answer

JavaScript

the csv file will look like:

JavaScript

this can help you, but, i realize that you don’t know how to do to edit your code, so…

change the

JavaScript

by

JavaScript

next, replace the if/else sentece by

JavaScript

i hope this can help you, and in the case, you can make the necessary corrections

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement