Jump to content

Recommended Posts

here's the code so far :

<form action="" method="post">
<textarea cols="80" rows="10" name="note" wrap="cirtual"><?php @ReadFile("guestbook.php"); ?></textarea>
</form>

 

the problem is when there's a button inside the html, like <input type="submit" value="submit" /> it leaves the textarea, what should i do to escape this??

what do you mean by "leaves the text area"?

 

And why would you have a button inside textarea tags?

 

leaves the text area, i'm trying to read the whole file inside the textarea, but when there's a submit button, the text area stops, and the button is shown in normal, see please the attachment.

 

i want to hav it inside the textarea because i'm trying to edit that file : guestbook ^^

 

[attachment deleted by admin]

$text = ReadFile("guestbook.php");
$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);

<form action="" method="post">
<textarea cols="80" rows="10" name="note" wrap="cirtual">
<?php echo stripslashes(htmlentities($text, ENT_QUOTES)); ?>
</textarea>
</form>

This is a better way:

 

<?php
if($_POST['Submit']){
$open = fopen("guestbook.php","w+");
$text = $_POST['update'];
fwrite($open, urldecode($text));
fclose($open);
echo "Updated";
}else{
$file = file("guestbook.php");
echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
echo "<textarea Name=\"update\" id=\"phpCode\"cols=\"50\" rows=\"10\">";
foreach($file as $text) {
echo $text;
}
echo "</textarea>";
echo "</br><input name=\"Submit\" type=\"submit\" value=\"Update\" onClick=\"document.getElementById('phpCode').value = escape(document.getElementById('phpCode').value)\"/>\n
</form>";
}
?>

Is it?

 

I was under the impression javascript can be disabled and should not be used to escape data...

 

Also "</br>" ???

 

Also, why are you only showing the form and escaping the data once the form is submitted. Escaping onclick of a button will not change the way it is displayed...

Is it?

 

I was under the impression javascript can be disabled and should not be used to escape data...

 

Also "</br>" ???

 

Also, why are you only showing the form and escaping the data once the form is submitted. Escaping onclick of a button will not change the way it is displayed...

 

If i didnt escape it, when i go back to the editor the file will not be the same as the original.

 

PS: This is a personal opinion.

 

</br> is just a habiit, he can remove if he'd like too.

 

However im new to php so looking forward to suggestions etc. Just thought I should try and contribute.

$text = ReadFile("guestbook.php");
$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);

<form action="" method="post">
<textarea cols="80" rows="10" name="note" wrap="cirtual">
<?php echo stripslashes(htmlentities($text, ENT_QUOTES)); ?>
</textarea>
</form>

 

thanks it ddnt work, but i rewrote your code and did this :

<?php
$text = file_get_contents("guestbook.php");
?>
<form action="" method="post">
<textarea cols="80" rows="10" name="note" wrap="cirtual">
<?php echo stripslashes(htmlentities($text, ENT_QUOTES)); ?>
</textarea>
</form>

 

so file_get_contents was the right option ^^

PS : i had to remove those lines :

 

$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);

they're not necessary since file_get_contents do the job..

$text = ReadFile("guestbook.php");
$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);

<form action="" method="post">
<textarea cols="80" rows="10" name="note" wrap="cirtual">
<?php echo stripslashes(htmlentities($text, ENT_QUOTES)); ?>
</textarea>
</form>

 

thanks it ddnt work, but i rewrote your code and did this :

<?php
$text = file_get_contents("guestbook.php");
?>
<form action="" method="post">
<textarea cols="80" rows="10" name="note" wrap="cirtual">
<?php echo stripslashes(htmlentities($text, ENT_QUOTES)); ?>
</textarea>
</form>

 

so file_get_contents was the right option ^^

PS : i had to remove those lines :

 

$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);

they're not necessary since file_get_contents do the job..

 

Then you wernt trying to edit the php source?, you wanted to edit the html?

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.