Topic awaiting preservation: All the right saves in all the wrong places (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Juneau, Alaska |
posted 07-28-2005 20:07
I'm writing a PHP application that allows the user to post a message that will be sent to a mySQL database. Right now I'm testing the output of the message by running a "preview" example after the message is submitted. I'm seeing that apostrophes and quotation marks are having saving backslashes appended in front of them. Also, line breaks are not being registered. code: <?php if (!isset ($title)){ //The initial interface echo " <form action=\"post.php\" method=post> Title: <input type=text name=\"title\" size=40> <br /> Name: <input type=text name=\"poster\" size=40> <br /><br /> <textarea name=\"actualpost\" rows=10 cols=50>Enter your post here. </textarea> <p /> <input type=submit name=\"preview\" value=\"Preview\"> </form> <br /> "; } elseif (isset($title)) { // prints the title and message, and includes a (currently useless) "submit" button echo " Here is a preview of what you are posting. Feel free to make any changes below. <p> <b>$title</b><br /> $actualpost </p> //The contents of $actualpost have now been modified by PHP. This is also shown in the textarea below. <form action=\"post.php\" method=post> Title: <input type=text name=\"title\" size=40 value=\"$title\"><br /> Name: <input type=text name=\"poster\" size=40 value=\"$poster\"> <br /><br /> <textarea name=\"actualpost\" rows=10 cols=50>$actualpost</textarea> <p /> <input type=submit name=\"preview\" value=\"Preview\"> <input type=submit name=\"send\" value=\"Submit\"> </form> <br /> "; } ?>
|
Maniac (V) Inmate From: under the bed |
posted 07-28-2005 20:46
nl2br - http://us3.php.net/manual/en/function.nl2br.php |
Bipolar (III) Inmate From: Juneau, Alaska |
posted 07-28-2005 22:01
Thanks, DL-44. The stripslashes function works perfectly. code: $actualpost = str_replace ("\n", '<br />', "$actualpost");
quote:
quote: . quote: . quote:
quote:
|
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 07-29-2005 03:46
You're going to need to filter that out. I suspect that preg_replace would likely work, but I defer to the others on that. |
Maniac (V) Inmate From: under the bed |
posted 07-29-2005 03:47 |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 07-29-2005 05:20
Instead of filtering you can do something like so: |
Bipolar (III) Inmate From: Juneau, Alaska |
posted 07-29-2005 21:38
quote:
quote:
|