PDA

View Full Version : A "control panel" for your website?



Infantry001
09-28-2008, 07:06 PM
Is it possible to have an "admin" page where you can edit the rest of your website in realtime?

What I mean by that is: if I log in to my admin page on my website and go to, say, "News", can I type the news (along with dates and such) into a text box, and then when I click submit, it re-writes the news.html file with the new info?

If you can, how would you go about doing that?

EDIT: Wow I feel stupid; of course it's possible. I just did it by creating this thread :duh: But I would still like to know how one would go about doing this.

Dan Cardin
09-28-2008, 07:07 PM
it would be a lot easier if you just made it a news.php file and had it access a database. Then you could just add to the database and it would automatically update the news.

EDIT: 3d buzz has a good video tutorial on it. If you dont want a video tutorial then,
http://www.tutorialized.com/view/tutorial/Create-A-Nice-News-System-In-PHP/35062

or googling php news tutorial :).

Infantry001
09-28-2008, 07:29 PM
Is php the only/easiest way to do this, though?

mixster
09-28-2008, 07:31 PM
CMS - Content Management Systems - is what it sounds like you want; it allows you to design and control many pages of a website online without a need for a software editor. If not, you generally will use PHP as it is straight forward. You don't have to use with a database system as PHP can write files, but will normally use a database because it allows for better access etc.
It can be very easy to do with basically all it needing is a page with an input field and submit button that puts the input field into the database then a separate page that echoes the content of the database for that page.

Dan Cardin
09-28-2008, 11:19 PM
Yup :), personally i think that php with a database is the best because its very customizeable and nifty. i dont see the need for a cms especially if its only one page, or if its a personal website.

im sure there are other ways of doing it though if you really dont want to. Although you dont even really need to write it yourself. Im sure there are plenty of free download-able ones, or take the source from a tutorial.

and really, the more complicated you make it the happier you'll be :).

Negaal
10-04-2008, 12:27 PM
Well, it's simple text editing, but works well... the textarea box only will be displayed when I click "Uuenda esilehte" from menu, and when I click submitbutton, the maincontent will be updated and it will not display the textarea box.

if you want I can give you source(though it's some few lines)

E: forgot this:

http://i38.tinypic.com/amyvtl.png

Infantry001
10-04-2008, 11:17 PM
Yeah, if I could get the source code, that'd be great!

Negaal
10-05-2008, 10:52 AM
Well, you have to create content file(newsfile.txt) manually.

cms.php:


<?

function procUpdateNews() {
$fn = "newsfile.txt";
$content = stripslashes($_POST['content']);
$fp = fopen($fn, "w") or die ("Error opening file in write mode!");
fputs($fp, $content);
fclose($fp) or die ("Error closing file!");
header("Location: cms.php");
}

if (isset($_POST["subupdatenews"])) procUpdateNews();

?>
<!--doesn't matter where form places, it's not visible.-->
<form action="" method="post" name="updateFormPrompt" style="margin:0px 0px; padding: 0px 0px;">
<input type="hidden" name="subdisplayUpdateForm" value="1">
</form>

<a href="javascript:document.updateFormPrompt.submit();" >Update</a>

<?
if (isset($_POST["subdisplayUpdateForm"])) {
?>

<h1>Update content</h1>
<p style="text-align:center">
<form name="updateform" action="<?$_SERVER['self']?>" method="post">
<textarea style="width:100%; height: 200px;" name="content">
<?
$fn = "newsfile.txt";
print htmlspecialchars(implode("",file($fn)));
?>
</textarea><br>
<input type="hidden" name="subupdatenews" value="1">
<input type="submit" value="Muuda">
</form>
</p>
<br><br>

<?
}
echo file_get_contents('newsfile.txt');
?>