/    Sign up×
Community /Pin to ProfileBookmark

strip slash textarea saving and viewing

Good day,
Here the context :

I’m openning a html file in a textarea, when I save the textarea it put slash in my code.

How can I strip those ?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 15.2006 — Where do you save the text: in a file or in a database? If in a database, then the slashes should be left in so as to help prevent database injection attacks (besides the fact that it will allow your query to work correctly in the first place). When you retrieve the data from the DB and want to display it in the browser, at that point use stripslashes() to remove them.
Copy linkTweet thisAlerts:
@PeuplarchieauthorFeb 15.2006 — Thanks NogDog !

your too good actualy it in your code.... see my other mesage, strip "" ....
Copy linkTweet thisAlerts:
@NogDogFeb 15.2006 — To maximize the portability of your code (so that it works whether or not "magic quotes" are turned on), use the following to strip slashes only when needed.
[code=php]
if(get_magic_quotes_gpc())
{
$text = stripslashes($text);
}
[/code]
Copy linkTweet thisAlerts:
@PeuplarchieauthorFeb 15.2006 — either I did'nt place the code a the good place or it just on't work this way...

Thnks for the fast answer !
Copy linkTweet thisAlerts:
@NogDogFeb 15.2006 — [code=php]
<?php
$file = "test.html";
if(isset($_POST['text']))
{
if(get_magic_quotes_gpc())
{
$_POST['text'] = stripslashes($_POST['text']);
}
$handle = fopen($file, "w") or die("Unable to open file for writing");
fwrite($handle, $_POST['text']);
fclose($handle);
}

$text = "";

if(is_readable($file))
{
$text = file_get_contents($file);
}
?>
[/code]
Copy linkTweet thisAlerts:
@PeuplarchieauthorFeb 15.2006 — for shure the only place I did'nt try !

with taht how can I go directly to the bottom of the textbox ?

Thanks !!!

I wish thing go well for you with that knowledge...
×

Success!

Help @Peuplarchie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...