creating an add page for my cms
Posted: Sat May 26, 2007 10:41 am
feyd | Please use
which feeds to this page[/syntax]
sql entries in the main table:
id
name
title
body
security
header
php
extra_head
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]
Now this usually works for me quite happily but I am now getting the following error:
Query failed: Column count doesn't match value count at row 1
This page basically adds a page to my cms by inputting data into mysql. It is a custom built cms but on other builds this file has worked. I would prefer to fix than to revert.
[syntax="html"]<html>
<head>
<title>Add page</title>
</head>
<body>
<form method="POST" action="add.php">
<table border="0" width="100%" height="672">
<tr>
<td height="26" width="23%" align="right">Name of page (for title
bar):</td>
<td height="26" width="75%">
<input type="text" name="name" size="50" tabindex="1"></td>
</tr>
<tr>
<td height="26" width="23%" align="right">Title of page:</td>
<td height="26" width="75%">
<input type="text" name="title" size="50" tabindex="2"></td>
</tr>
<tr>
<td height="488" width="23%" align="right">Body of page:</td>
<td height="488" width="75%">
<textarea rows="25" name="body" cols="72" tabindex="3"></textarea></td>
</tr>
<tr>
<td height="26" width="25%" align="Right">Security Level:</td>
<td height="26" width="25%">
<select name="security" size="1" tabindex="4">
<option selected value="10">Normal</option>
<option value="9">Full Members</option>
<option value="7">Full Members</option>
<option value="6">Filmmakers</option>
<option value="5">Moderators</option>
<option value="4">Writer</option>
<option value="3">Employee</option>
<option value="2">Admin</option>
<option value="1">Owner</option>
</select>
</td></tr>
<tr>
<td height="26" width="25%" align="right">Which Category:</td>
<td height="26" width="25%">
<select name="header" size="1" tabindex="5">
<option value="1">Film</option>
<option value="2">News</option>
<option value="3">Learning</option>
<option value="4">Admin</option>
</select>
</td>
</tr>
<tr>
<td height="26" width="25%" align="right">Php:</td>
<td height="26" width="25%">
<select name="php" size="1" tabindex="6">
<option value="1">Yes</option>
<option selected value="0">No</option>
</select>
</td>
</tr>
<tr>
<td height="30" width="100%" colspan="2">
<input type="submit" value="Submit" name="B1" tabindex="7">
<input type="reset" value="Reset" name="B2" tabindex="8">
</td>
</tr>
</table>
</form>
</body>
</html>which feeds to this page[/syntax]
Code: Select all
<?php
$name = $_POST["name"];
$title = $_POST["title"];
$body = $_POST["body"];
$security = $_POST["security"];
$header = $_POST["header"];
$php = $_POST["php"];
if(!$name || !$body)
{
echo "Please go back and ensure that all fields have been filled in";
exit;
}
require("database.php");
if(!get_magic_quotes_gpc())
{
$name = addslashes($name);
$title = addslashes($title);
$body = addslashes($body);
}
$query = "insert into main VALUES
('', '".$name."', '".$title."', '".$body."', '".$security."', '".$header."', '".$php."')";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close($db);
?>
<html>
<head>
<?php
echo "<meta http-equiv=\"refresh\" content=\"4; URL=http://talote.co.uk/" . $id . "\">";
?>
<title>Page added</title>
</head>
<body>
The "<?php echo $title; ?>" page has been added to the site.
<br />
Please wait to be sent back to the main page
</body>
</html>sql entries in the main table:
id
name
title
body
security
header
php
extra_head
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]