Hi i have a database with storys in it and the user can upload but i cant work out how to get the edit function to update the database.
The forum
The uploader
The forum
Code:
<?php
$host = "";
$username = "";
$password = "";
$database = "";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$db = mysql_select_db($database, $server);
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM `storys` WHERE id = $id");
$row = mysql_fetch_row($sql);
?>
<form name="story" action="edit/story_edit_uploader.php?id=<?php print $id?>" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="story_title">Edit your story</td><td class="story_title"></td>
</tr>
<tr>
<td class="green">Poster</td>
<td><div align="right">
<input type="text" name="poster" value="<? print "$row[1]"; ?>" disabled="disabled" />
</div></td>
</tr>
<tr>
<td class="green">Author</td>
<td><div align="right">
<input type="text" name="author" value="<? print "$row[2]"; ?>" />
</div></td>
</tr>
<tr>
<td class="green">Title</td>
<td><div align="right">
<input type="text" name="title" value="<? print "$row[3]"; ?>" />
</div></td>
</tr>
<tr>
<td colspan="2"><textarea name="body" cols="80" rows="40" value="<?php
print nl2br($row[4]);?>" ></textarea></td>
<tr>
<td><input name="bn_submit" type="submit" value="Submit Edit" /></td>
<td> </td>
</tr>
</table>
</form>
The uploader
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Upload</title>
<meta http-equiv="Refresh" content="1;URL=../stories.php" />
</head>
<body>
<?php
//story upload
$host = "mysql10.streamline.net";
$username = "";
$password = "";
$database = "";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
//grab data from form
$id = $_GET['id'];
$poster = $_GET['poster'];
$author = $_POST['author'];
$title = $_POST['title'];
$body = $_POST['body'];
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$sql_phrase = 'INSERT INTO `storys` (`id`, `poster`, `author`, `title`, `body`) VALUES (\''.$id.'\, \''.$poster.'\', \''.$author.'\', \''.$title.'\', \''.$body. '\');';
$sql = mysql_query($sql_phrase);
if(!$sql) {
echo "There was an error, please try again.";
print mysql_error();
}
else
echo "uploaded";
?>
</body>
</html>