Skip to main content
Go7hic13
Known Participant
June 19, 2012
Question

stripslashes function in PHP? Doesn't seem to work...

  • June 19, 2012
  • 1 reply
  • 9586 views

I've been trying to get the stripslashes() function in a PHP script to work but I'm not having any luck.  It seems like a very straightforward function but I'm still ending up with slashes in my comment/text area data.  Can anyone help?  I have some PHP books but they barely touch on the functionality.  (I'm new to PHP).  Thanks!  (BTW...  I removed the various attempts at calling the stripslashes() function).  The field I'm trying to remove the slashes from is the 'comment' variable.

Here is my short php script:

<?php // Script 1.0 - contactlist.php

if (isset($_POST['submit']) && !empty($_POST['submit'])) // Test if submit button named submit was clicked and not empty

{

          if (!empty($_POST['first']) && !empty($_POST['last'])  && !empty($_POST['email']) && !empty($_POST['phone']) && !empty($_POST['comment'])) {

                    $body = "First Name: {$_POST['first']}\nLast Name: {$_POST['last']}\nEmail Address: {$_POST['email']}\nContact Phone Number: {$_POST['phone']}\nContact Preference: {$_POST['contactvia']}\n\nBest Time To Contact: {$_POST['timepref']}\n\nComments:\n {$_POST['comment']}";

                    $body = wordwrap($body, 70);

                    mail('someone@somewhere.net', 'NEW Customer Inquiry Submission',$body, "From: {$_POST['email']}");

                    header('Location: index.html');  //Redirect to new url if form submitted

     }

}

?>

This topic has been closed for replies.

1 reply

Participating Frequently
June 19, 2012

Why are you needing to remove the slashes? Is magic quotes enabled? Are you using addslashes() somewhere?  What version of PHP are you running?

Go7hic13
Go7hic13Author
Known Participant
June 19, 2012

I'm assuming magic quotes is enabled.  I'm running sql/php v5.0 I believe.  I'm not adding any slashes either...  They are just there whenever I use a quote in the comment field.

Go7hic13
Go7hic13Author
Known Participant
June 19, 2012

Sorry...  It looks like I have PHP v5.3