Technical Help & Discussion > Website Design & Programming
PHP
Hiatus:
I'm hoping there are other web developers out there who can help me out here...
I am having trouble with this code, and it has been bugging me for a long time now. I just can't get it to work.
This is what I have:
[LOTS OF CODE]
<?
if($_SESSION['login'] && $_SESSION['admin'] && $_GET['action'] == 'edit') {
?>
<FORM METHOD="POST" ACTION="<? echo $_SERVER['PHP_SELF']; ?>?action=update">
<?
$path = $_SERVER['PATH_TRANSLATED'];
$data = file_get_contents($path) or die('Could not read file.');
$content = htmlentities($data, ENT_NOQUOTES, 'ISO-8859-1');
?>
<p> Page Name: </p>
<center><input type="text" name="page_name" value="<? echo $_SERVER['PATH_TRANSLATED']; ?>" style="background-color: #000000; border: 1px solid grey; width: 500px; height:20px;">
<p> Page Content: </p>
<textarea name="page_content" wrap="off" rows=19 cols=80 style="background:transparent; color: #FFFFFF; border: 1px solid grey;"> <? echo $content; ?> </textarea>
<input type="Submit" value="Update Page" style="position: relative; background-color: #000000; font-family: Impact; font-size: 12px; border:1px solid grey; width:70px; height:20px;"></center>
</FORM>
<?
} else if($_SESSION['login'] && $_SESSION['admin'] && $_GET['action'] == 'update') {
$file = $_POST['page_name'];
$content = $_POST['page_content'];
// $fh = fopen($file, 'w') or die('Could not open file.');
echo $_POST['page_content'];
// fwrite($fh, $content) or die('Could not write to file.');
// fclose($fh);
?>
<center>
Updated...
<a href="index.php">Home[/url]
</center>
<?
} else {
[ETC...]
The problem I am having is that when the textarea is posted, it (somehow) messes up the code and puts a "\" before every single and double quote. I don't know why it is doing this to me. If I can figure this out, it would work perfectly...
I hope this makes sense. I can probably clarify more if need be. I hope someone can help. Thanks.
sam:
clarification needed here...could be my mind not working (long week) but i dont have a clue what you are on about in your text....how long is the code, did you write it? what version of php are u using?
Hiatus:
The code that I posted is just part of the file. I can send the rest to you in a private message if u want...either PM me or post here if u want the rest. I don't really want to post it all online if I can avoid it.
I wrote most of it, but also did a bit of research on the web for some stuff (like the "htmlentities()"...I had never heard of it until now...)
Also, I believe I am running PHP 4.3.10.
sam:
so you reckon the htmlentities is where it is going wrong.. ill have a think about that.
sam:
oh one other thing are you sure all the function you are running are compatible with that version of php
Navigation
[0] Message Index
[#] Next page
Go to full version