admin panel for php page

bnrj_sjy

New Member
Messages
18
Reaction score
0
Points
0
i have created a php page with dreamweaver having an article and a heading inside the page

now i want to create an admin panel for that page so that i can change the contents of that page so that i dont have to upload the php page evry time i make a change

thanks

help needed urgent
 

webmatrix

New Member
Messages
2
Reaction score
0
Points
0
its easy dude but need lots of work you have to create database for this if you can post your php page i will try to help u out :)
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
cPanel->FileManager->Edit is not an option?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
What you want to create is basically a dynamic page. As it has been said before, you have different options: updating in DW and uploading, editing from cPanel, creating a database or XML file backend and creating an management utility, or creating a management utility that directly edits the page.

I personally recommend the database/XML file approach but you can choose.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
What you want to do is just change the heading and change the contents of the article?
 

smithee

New Member
Messages
45
Reaction score
2
Points
0
I've done a pretty basic model of some sort, but it actually writes to a text file rather than an XML, mainly because it was a lot easier to handle and you can even add your own HTML inside it (whereas in XML it may complain about this!). Here's my version (somewhat rather basic!):

http://csmith.x10hosting.com/editpagetest/editpage_form.php

And here's the related code snippets... I've only put in the relevant stuff, such as the PHP code where it would normally be hidden from the browser. This one is on editpage_form.php, where you edit the page on:

HTML:
<form id="form1" name="form1" method="post" action="editpage_show.php">
    <textarea name="page_content" cols="100" rows="10" wrap="soft" style="font-family:Verdana, Arial, Helvetica, sans-serif; color:#0000FF;"><?php if (file_exists("page.txt")) { echo file_get_contents("page.txt"); } ?></textarea>
    <br />
    <input name="save_btn" type="submit" value="Save" />
</form>

And this one is where you see your page you've just created, in editpage_show.php:

PHP:
<?php
if (isset($_POST['page_content'])){
    // To create/overwrite the text file
    $textFile = fopen("page.txt","w+b");
    // To load the content of the text box and format it accordingly
    $content = $_POST['page_content'];
    $content = htmlentities($content,ENT_QUOTES); 
    $content = str_ireplace("\\&quot;","&quot;",$content);     
    $content = str_ireplace("\\& #039;","& #039;",$content); //delete the spaces between the & and #039;
    $content = str_ireplace("&lt;","<",$content); 
    $content = str_ireplace("&gt;",">",$content); 
    // Writes the new content to the file
    fwrite($textFile,$content);
    // Closes the file writing session
    fclose($textFile);
} else {
    // Checks to see if text file exists, and exit if it doesn't
    if (!(file_exists('page.txt'))) {
        exit('Failed to open page.txt.');
    }
}
// Grabs the content of the text file, and formats it accordingly (again!) 
$content = "<p>".file_get_contents("page.txt")."</p>";
$content = str_ireplace("\r\n","</p><p>",$content);
// Displays the formatted test
echo $content; 
?>

Any problems or other queries, just give a reply :biggrin:

Edit: Whenever you start a new line by hitting return/enter, it automatically adds paragragh tags to the final page... I'll make this better as the days go by
 
Last edited:

bnrj_sjy

New Member
Messages
18
Reaction score
0
Points
0
thanks very much for the help
will be back to you if required any further help
 

bnrj_sjy

New Member
Messages
18
Reaction score
0
Points
0
dear smithee

i have managed to make my content as you have guided me

but now a problem arises
it is that

when i have uploaded to my server it takes a \ (backslash) behind every quotes (" , ')

how to solve it please help me

and many many thanks for all previous helps
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
If $content is what has been uploaded, try

PHP:
$stripped_content = stripslashes(  $content ) ;

stripslashes() in the PHP Manual
 
Top