Jump to content

Stop that back slash..!


manalnor

Recommended Posts

Hello friends,

 

I've php script that create files for example you enter

file name (ex : test.php)

file content (ex: any text )

it will create test.php file with the same content you entered.

 

 

but the problem it add back slah \ before " or '

how can i stop it and make it not add back slash before " and '

 

 

here is the code

 

<?php
function saveFile($filename,$filecontent){
if (strlen($filename)>0){
$file = @fopen($filename,"w");
if ($file != false){
fwrite($file,$filecontent);
fclose($file);
return 1;
}
return -2;
}
return -1;
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
File name: <input name="filename" type="text" value="<?php echo $domainbase; ?>" />
File content: <textarea name="filecontent" rows="15" cols="46"></textarea>
<input type="submit" name="submitBtn" value="Save file" />
</form>

<?php
if (isset($_POST['submitBtn'])){
$filename    = (isset($_POST['filename']))    ? $_POST['filename']    : '' ;
$filecontent = (isset($_POST['filecontent'])) ? $_POST['filecontent'] : '' ;
if (saveFile($filename,$filecontent) == 1){
echo "File was saved";
} else if (saveFile($filename,$filecontent) == -2){
echo "An error occured during saving file";
} else if (saveFile($filename,$filecontent) == -1){
echo "Wrong file name";
}
}
?>

 

thank you alot

it will really helps me alot  :D

Link to comment
https://forums.phpfreaks.com/topic/212320-stop-that-back-slash/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.