I have being having some difficulty with a form but i have finally got it functioning semi correct. The problem now is that when the variables are passed to the page they are not in the correct position. Sounds crazy!
The code:
<input name="noformat" type="text" class="box" id="noformat" value="<?=$noformat;?>">
Doesn't actually display the variable 'noformat' it displays the variable 'message' instead. I can't figure this out. Here is the complete php code for the page in question
<?php
include 'dbconnect.php';
if(isset($_GET['id']))
{
$query = "SELECT title, content, link, rss, noformat, message, user, keyword FROM mynews WHERE id = '{$_GET['id']}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content, $link, $rss, $noformat, $message, $user, $keyword) = mysql_fetch_array($result, MYSQL_NUM);
}
else if(isset($_POST['title']))
{
$id = $_POST['id'];
$title = $_POST['title'];
$content = $_POST['content'];
$link = $_POST['link'];
$rss = $_POST['rss'];
$noformat = $_POST['noformat'];
$message = $_POST['message'];
$user = $_POST['user'];
$keyword = $_POST['keyword'];
$query = "UPDATE mynews SET title = '$title', content = '$content', user = '$user', rss = '$rss', message = '$message', noformat = '$noformat' keyword = '$keyword', link = '$link' WHERE id = '$id'";
mysql_query($query) or die('Error : ' . mysql_error());
echo "<p align='center'>Article updated</p>";
$title = addslashes($title);
$content = addslashes($content);
$user = stripslashes($user);
$rss = stripslashes($rss);
$message = stripslashes($message);
$noformat = stripslashes($noformat);
$keyword = stripslashes($keyword);
$link = stripslashes($link);
}
?>
<form method="post" action="editcontent.php">
<input type="hidden" name="id" value="<?=$id;?>">
<table width="700" border="0" cellpadding="2" cellspacing="1" class="box" align="center">
<tr>
<td width="100">Title</td>
<td><input name="title" type="text" class="box" id="title" value="<?=$title;?>"> </td>
</tr>
<tr>
<td width="100">Content</td>
<td>
<input name="content" type="text" class="box" id="content" value="<?=$content;?>"></input>
<?php echo "$content" ?></td>
</tr>
<tr>
<td>User</td>
<td><input name="user" type="text" class="box" id="user" value="<?=$user;?>">
<?php echo "$user" ?></td>
</tr>
<tr>
<td>RSS</td>
<td><input name="rss" type="text" class="box" id="rss" value="<?=$rss;?>"><select name="rss" id="rss">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
<?php echo "$rss" ?></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message" cols="45" rows="12" class="box" id="message"><?=$message;?>
</textarea>
<?php echo "$message" ?></td>
</tr>
<tr>
<td>RSS Content </td>
<td><input name="noformat" type="text" class="box" id="noformat" value="<?=$noformat;?>">
<?php echo "$noformat" ?></td>
</tr>
<tr>
<td>Keyword </td>
<td><input name="keyword" type="text" class="box" id="keyword" value="<?=$keyword;?>">
<?php echo "$keyword" ?></td>
</tr>
<tr>
<td>Link</td>
<td><input name="link" type="text" class="box" id="link" value="<?=$link;?>">
<?php echo "$link" ?></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="update" type="submit" class="box" id="update" value="Update Article"></td>
</tr>
</table>
<p align="center"><a href="test2.php">Back to admin page</a></p>
</form>