I have a form that once filled out puts the data into a database and sends a confirmation email back to client.
Before I insert into database, I return the information to the browser for the client to check for accuracy. If client clicks on the continue button (submit), I do some formatting to the variables:
$description = trim(addslashes(nl2br($_SESSION['description'])));
I then insert $description into the database.
$query = "INSERT INTO DB set first_name = '$first_name', last_name = '$last_name', address= '$address', address_2 = '$address_2', city = '$city', state = '$state', zip = '$zip', description = '$description', file_date = '$file_date'";
If the data is successfully added to database, I send out a reply email to the client. To do so, I again format the data by stripping slashes and then put that into the email:
$description = stripslashes($description);
My problem is that in the email, the slashes are not removed. The nl2br formatting is there but not the stripslashes. My php ini file has magic_quotes on but I add and strip slashes as a practice anyway. Anybody have a clue as to why the stripslashes function is not working in the email?
Second question is about nl2br(). Once that formatting is done prior to inserting into a database, do I have to use nl2br again when ever that data is returned? Is it a onetime function?