Jump to content

Recommended Posts

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!

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>

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.