home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Practical Internet Web Designer 89
/
PIWD89.iso
/
pc
/
CONTENTS
/
DEVELOPER
/
TUTORIAL_FILES
/
Pages90-91
/
admin
/
add.php
next >
Wrap
PHP Script
|
2003-11-23
|
2KB
|
67 lines
<?php
//connect to the database
$conn = mysql_connect("localhost","root","pwd");
//choose the cms db
mysql_select_db("cms", $conn);
if ($_POST['btnAdd'] != "")
{
$sql = "INSERT INTO tblContent (contentTitle, contentText, catID) VALUES ('" . $_POST['contentTitle'] . "','" . $_POST['contentText'] . "'," . $_POST['catID'] . ")";
if (mysql_query($sql, $conn))
{
$new = true;
}
}
//query the database for a list of categories
$result = mysql_query("SELECT catID, catName, catDesc FROM tblCat", $conn);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>CMS Homepage</title>
<link rel="stylesheet" type="text/css" href="../global.css" />
</head>
<body>
<div id="banner">
<p> </p>
</div>
<div id="navigation">
<ul class="main">
<li><a href="add.php">Add Content</a></li>
<li><a href="edit.php">Edit Content</a></li>
</ul>
</div>
<div id="content">
<h1>Add Content</h1>
<?php
if($new == true)
{?>
<p><strong>Your new article has been added.</strong></p>
<?php
}
?>
<form method="post" action="add.php">
<p>Title:
<br /><input name="contentTitle" id="contentTitle" class="text" /></p>
<p>Content:
<br /><textarea name="contentText" id="contentText" class="largeText"></textarea></p>
<p>Category:
<br /><select name="catID" id="catID">
<?php
while ($row = mysql_fetch_array($result)) {?>
<option value="<?=$row['catID']?>"><?=$row['catName']?></option>
<?php
}
?>
</select></p>
<p><input type="submit" name="btnAdd" value="Add Item" class="submit" /></p>
</form>
</div>
</body>
</html>