Simple - Adding stripslashes...but how?
Posted: Mon Mar 05, 2007 8:43 pm
The script below works great except I'm a bit clueless on where I actually have to apply (and how I would apply) stripslashes() as PHP is adding escaping slashes to the output!
I've tried...
stripslashes($_POST['template']);
stripslashes($file);
stripslashes($template);
on the line before fopen.
I've tried...
stripslashes($_POST['template']);
stripslashes($file);
stripslashes($template);
on the line before fopen.
Code: Select all
<?php
$template = basename($_SERVER['HTTP_REFERER']);
if(isset($_SERVER['HTTP_REFERER'])) {
echo 'The referer page is: <b>' . $template .'</b> <br />';
}
else if(!isset($_SERVER['HTTP_REFERER'])) {
echo 'No referrer set!';
echo '<br />php dies';
die();
}
if (isset($_POST['template']) && isset($_POST['textarea'])) {
$template = $_POST['template'];
$file = fopen($template, 'w');
fwrite($file, $_POST['textarea']);
fclose($file);
?>
<span style="#f00">The changes have been saved and will show as follows.</span>
<form>
<textarea name="textarea2" cols="64" rows="16" disabled="disabled"><?php readfile($template);?></textarea>
</form>
<?php
} else {
$template = basename($_SERVER['HTTP_REFERER']);
if(isset($_SERVER['HTTP_REFERER'])) {
echo 'The referer page is: <b>' . $template .'</b> <br />';
}
?>
<form method="post" action="<?php echo 'edit.php';?>">
<textarea name="textarea" cols="64" rows="16"><?php readfile($template);?></textarea>
<input type="hidden" name="template" value="<?php echo $template;?>" />
<br><input type="submit" name="Submit" value="Submit"></form>
<?php
}
?>