disbeliever Posted February 5, 2008 Share Posted February 5, 2008 Hello all, I am new to php and having issues with a simple cms system im working on. There is an itemmodify page that pulls back the data from the database, but for the content I do an include which pulls in an editor and textarea that you can edit the content in. However, when I click submit, the update query cannot pick up the value of the included textarea, and I cannot figureout why. When I hard code in a value in the update sql statement to replace the textarea's value, the update works. The code is two pages as follows: <? require "auth.php"; require "./dbfunctions.php"; $id = $_GET['id']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Modify Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> </head> <body> <span class="titel1">Modify Page</span> <br> <? if(!isset($_GET['id'])) { echo "wrong parameters"; exit; } /*//---------------------------------- // DELETE PACKSHOT //---------------------------------- if($_GET['mode']=="delete") { $id = $_GET['id']; // foto uit database halen $query = "UPDATE `shop_artikel` SET `foto` = '0' WHERE `id` = '$id' "; mysql_query($query,$link) or die("foto niet verwijderd uit database"); $queryke = "SELECT foto from shop_artikel where id = $id"; $resulteke = mysql_query(queryke); while($rij = mysql_fetch_object($resulteke)){ $foto_naam = "$rij->foto"; } // foto en thumb deleten if (!unlink("$abspackpath/$foto_naam")) exit("error bij deleten van foto {$abspackpath}/{$foto_naam}"); if (!unlink("$abspackpath/thumb_$foto_naam")) exit("error bij deleten van thumb"); } //---------------------------------- // EINDE DELETE PACKSHOT //----------------------------------*/ if ($_POST['submit']) { database_connect(); //--- TESTen $id = $_GET['id']; $titel = $_POST['titel']; $trefwoorden = $_POST['trefwoorden']; $tekst = $_POST['Body']; echo $tekst; //begin image uploaden if($titel=="") $foutbericht .= "Please fill in a title.<br>"; if (!$foto==0) { $fotovar = $foto; }else if (!isset($error_toevoegen)){ $fotovar = $foto_naam; } else { $fotovar = 0; } if($foutbericht) echo "<br>" . $foutbericht . "<br><input name=\"back\" type=\"button\" value=\"< Back\" onClick=\"history.go(-1)\">"; else { $sql = "UPDATE content SET title='$titel', keywords='$trefwoorden', text='$tekst' WHERE id='$id'"; } $query = mysql_query($sql)or die("There's a problem with the query: ". mysql_error()); if($query) echo "<br>The page is succesfully edit.<br><br>\n<a href=\"item_list.php\" target=\"links\"><img src=\"../img/ico_overview.gif\" width=\"19\" height=\"19\" border=\"0\" alt=\"Pages\"></a> <a href=\"item_detail.php?id=$id\"><img src=\"../img/ico_detail.gif\" width=\"19\" height=\"19\" border=\"0\" alt=\"More info\"></a> <a href=\"item_modify.php?id=$id\"><img src=\"../img/ico_edit.gif\" width=\"19\" height=\"19\" border=\"0\" alt=\"Edit\"></a>"; } else { database_connect(); $id = $_GET['id']; $select = "SELECT * FROM content where id = '$id'"; $query = mysql_query($select); $nieuws = mysql_fetch_object($query); $deid = $nieuws->id; $titel = $nieuws->title; $trefwoorden = $nieuws->keywords; $tijd = $nieuws->posting_time; $tekst = $nieuws->text; ?> <form action="" method="post" enctype="multipart/form-data" id="Compose" name="Compose"> <table border="0"> <tr> <td class="titel3">title</td> <td><input name="titel" type="text" value="<? echo $titel; ?>" size="10" maxlength="20"></td> </tr> <tr> <td class="titel3" width="75">time of posting</td> <td><input disabled name="tijd" type="text" value="<? echo timestamp2datime($tijd); ?>" size="25" maxlength="50"></td> </tr> <tr valign="top"> <td width="75" class="titel3">keywords</td> <td><textarea name="trefwoorden" cols="30" rows="3" id="trefwoorden"><? echo $trefwoorden; ?></textarea></td> </tr> <tr valign="top"> <td width="75" class="titel3">text</td> <td> <? include("editor/editor.php"); ?></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" value="submit" onClick="SetVals()"></td> </tr> </table> </form> <? } ?> </body> </html> this pulls from the database all content for a certain ID thst is passed, and that works. Then at the bottom of that you can see the include. which pulls in: <? database_connect(); $query = "SELECT * FROM content where id = '$id' "; $query = mysql_query($select); $nieuws = mysql_fetch_object($query); $deid = $nieuws->id; $titel = $nieuws->text; ?> <DIV style="LEFT: 0px; POSITION: relative; TOP: 0px; HEIGHT: 290px;" width="100%" class="semitrans"> <TEXTAREA style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px" name="Body"></TEXTAREA> <DIV id="plainmsg" style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"> <? echo $titel; ?> </DIV> I can get the right id content into the textarea, but on submit to the update statement, a null value is inserted in the contents place. Can someone please help me? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/89590-need-help-with-included-textarea-and-update/ Share on other sites More sharing options...
timmah1 Posted February 5, 2008 Share Posted February 5, 2008 From what I'm looking at, it don't look like your displaying a value for the textarea to update <TEXTAREA style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px" name="Body"></TEXTAREA> <DIV id="plainmsg" style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"> <? echo $titel; ?> </DIV> Try this <TEXTAREA style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px" name="Body"> <DIV id="plainmsg" style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"> <? echo $titel; ?> </DIV> </TEXTAREA> Quote Link to comment https://forums.phpfreaks.com/topic/89590-need-help-with-included-textarea-and-update/#findComment-458978 Share on other sites More sharing options...
disbeliever Posted February 5, 2008 Author Share Posted February 5, 2008 Love your av, TIMMAH! I will try thatnow and let you know, thanks! From what I'm looking at, it don't look like your displaying a value for the textarea to update <TEXTAREA style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px" name="Body"></TEXTAREA> <DIV id="plainmsg" style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"> <? echo $titel; ?> </DIV> Try this <TEXTAREA style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px" name="Body"> <DIV id="plainmsg" style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"> <? echo $titel; ?> </DIV> </TEXTAREA> Quote Link to comment https://forums.phpfreaks.com/topic/89590-need-help-with-included-textarea-and-update/#findComment-459000 Share on other sites More sharing options...
disbeliever Posted February 5, 2008 Author Share Posted February 5, 2008 wow i feel such the fool. Ive been tearing through code for days and i just misplaced the content in the textarea thanks alot man I owe ya. If you ever need help with flash or actionscript, im your man. Quote Link to comment https://forums.phpfreaks.com/topic/89590-need-help-with-included-textarea-and-update/#findComment-459018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.