×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Quotes being escaped in form data?

Quotes being escaped in form data?

Quotes being escaped in form data?

(OP)
Hi,

I'm new to PHP, but I know a lot of Perl (5 years, playing in my spare time).

Anyway, I'm playing with a simple guestboard-script (see below) and
everything can be submitted, except quotes (" and '), they are escaped like: \" or \'

this creates problems when a URL is submitted like:
<a href="url">blah</a>
it comes out as: <a href=\"url\">blah</a>
which doesn't work.
leaving the "'s does work, but that isn't intuitive (from the user's
perspective)

What am I doing wrong?

Cheers

Simon

----- php code below ----

<?
/*

annotate.php3  

This is a module that can be placed on any php3 page to allow users to
add
their comments. The comments are stored in a file in the current
directory,
whose name is constructed by adding ".comment" to the calling page's
name,
and merged into the calling page dynamically. (The calling page is not
modified.)

I wrote this because I wanted a simple way to add this functionality to
my
pages without requiring that mySQL be available.

In the message input, blank lines are converted to paragraph tags. No
other
conversions are applied. If you don't want your users to be able to
input
html, uncomment the "strip_tags" line.

Note that the directory must be writable by the web server.

Put this module in some convenient location and then embed it in your
pages
like so:

require("/some/full/path/annotate.php3");
or, relative to the docroot:
require($DOCUMENT_ROOT . "/relativepath/php3");

Steve Yelvington <steve@yelvington.com>
*/
$commentdir = "annotate/";
$commentfile = $commentdir . basename($PHP_SELF) .  ".comment";
/* print "<br><b>$commentfile</b><br>"; */

if ($message)
    {
     /* uncomment the next two lines to strip out html from input */
     /* $name = strip_tags($name); */
     /* $message = strip_tags($message); */
    $message = ereg_replace( "\r\n\r\n",  "\n<P>", $message);
    $message = ereg_replace( "\r\n",  "\n<BR>", $message);
    $date = date( "l, F j Y, h:i a");
    $message =  "\n<p><B>$name </B> -- $date</p>\n<P>$message
</P>\n<HR>\n\n";
    $fp = fopen ($commentfile,  "a");
    fwrite ($fp, $message);
    fclose ($fp);
    print "<P><B>bericht:</b></p>\n<p>$message</p><p>Toegevoegd</p>\n";
    print "<hr><p><a href=\"". basename($PHP_SELF) . "\">Klik hier om
het hele board te zien</a>";
    }
else {
    @readfile($commentfile);
}
?>
<P>
<FORM method="post">
<b>Naam:</b><BR><INPUT name="name" type="text" size="55"><BR>
<b>Bericht/opmerking:</b><BR><TEXTAREA name="message" rows=10 cols=55
wrap=virtual>
</TEXTAREA><BR>
<INPUT name="submit" type="submit" value="Post your comments">
</FORM>

RE: Quotes being escaped in form data?

(OP)
I've already solved it myself, using the function: stripslashes did the trick!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close