Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.