Page 1 of 1

CMS Problems

Posted: Tue Dec 04, 2007 1:05 pm
by grandman
Hello,

I have a problem (brick-wall/mental-block) Are there any good tutorials on how to add a new file/page via a cms?

I'm writing the cms, and have all the existing files/page covered, but have stopped at how to add a new one. I just don't seem able to comprehend how I make "New File" happen on the fly :?

Kind Regards

G)

Posted: Tue Dec 04, 2007 1:09 pm
by alex.barylski
You need to sit down and think somemore then. :P

There are about 100 different ways to make appear on the fly.

1) Save HTML to a static text file and have the file requested manually is one method.
2) Save HTML inside a templateized PHP script (my own CMS does that: http://www.sourceforge.net/projects/texocms)
3) Using a single application entry point (index.php) and pull contents togather dynamically.

The latter is likely the most common and by far most powerful and flexible. There are many many different ways to implement a page controller style web page.

Do you load modules?
Do you loads and embed entire applications?

There are tons of other questions to ask, depending on the complexity of the CMS.

Posted: Tue Dec 04, 2007 1:25 pm
by staar2
Hm store page content in database

Posted: Tue Dec 04, 2007 2:35 pm
by grandman
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello,

I don't want to use any "HTML" static pages. I'm looking to achieve a full db run website. There are eight areas and some one hundred++ pages.

There will be two different styles, run from two different style sheets, hoping to use a similar banner rotation system to rotate style sheets, at pre-determined time intervals.

I tam working with this simple example for new pages and altering existing ones:

New page:

Code: Select all

<?php
if (!get_magic_quotes_gpc () ) {
$GET = array_map('addslashes', $_GET);
$POST = array_map('addslashes', $_POST);
$COOKIE = array_map('adds;ashes', $_COOKIE);
$REQUEST = array_map('addslashes', $_REQUEST);

?>

<?php 

$name = $_POST['name'];
$email = $_POST['email'];
$sql = "INSERT INTO tablename SET
name='$name',
email='$email'";

if (@mysql_query($sql)) {
echo '<p> new file added</p>';
}else {
echo '<p> Error adding new file: ' . mysql_error() . '</p>';
}

?>

<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Add New author</a></p>
<p><a href="index.php">Return To index</a></p>


<?php else:  ?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Enter New file:</p>
<label> name: <input type = "text" name ="name" /> </label><br />
<label> addressl: <input type "text" Name ="addressl" /> </label><br />
<input type ="submit" Value = SUBMIT" />
</form>

<?php endif; ?>

?>
editing something like this:

Code: Select all

if (isset($_POST['name'])):

$name = $_POST['name'];
$addressl = $_POST['addressl'];
$id = $_POST['id'];
$sql = "UPDATE tablename SET
		name='$name',
		addressl='$addressl'
		WHERE id='$id'";
		
		if (@mysql_query($sql)) {
		echo '<p>file details updated</p>';
		}else{
		echo '<p>Error updating file details: ' . mysql_error() . '</p>';
		
}
?>

<p><a href="index.php">return to index</a></p>

<?php 

else:

$id = $_GET['id'];
$name = @mysql_query (
"SELECT name, address FROM tablename WHERE id='$id'");

if (!$address) {
exit('<p> Error getting address details ' . mysql_error() . '</p>');

}

$address = mysql_fetch_array($address);

$name = $address['name'];
$address = $address['address'];

$name = htmlspecialchars($name);
$address = htmlspecialchars($address);

?>

<form action = "<?php echo $_SERVER['php_SELF']; ?>" method="post">
<p>Edit the author</p>
<label>Name:<input type="text" name="name" value="<?php echo $name; ?>"></label><br />
<label>addressl: <input type="text" name="address" value="<?php echo $address; ?>"></label><br />
<input type="hidden" name="id" value="<?php echo $id ?>" />
<input type="submit" value="SUBMIT" />
</form>

<?php endif; ?>
Not working yet, and I'm missing something big, but not sure what???

G)


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]