Update code doesn't work with textarea

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stwallace
Forum Newbie
Posts: 3
Joined: Sat Oct 07, 2006 11:43 pm

Update code doesn't work with textarea

Post by stwallace »

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]


I've created forms using PHP Database Wizard (great program)

The update forms don't seem to work if I used a textarea.  Sometimes a form will allow me to update 2 to 3 times but on the 4th time it will come back blank. Here is a sample of my code. You can see it in action at http://www.cottonsseptic.com/admin/index.html The site is not protected and this time but the forms are not connected to the main pages so feel free to test.

Any help will be greatly appreciated.

Thank you

Sharon

Code: Select all

<?php
include('general/header.inc');
require_once('general/general.php');

if (!(isset($_POST['SubmitForm_x'])))   {
$whereStmt = ' aboutid="'.addslashes($_GET['aboutid']).'" AND  about="'.addslashes($_GET['about']).'"';
$selectSql = 'SELECT * FROM about WHERE '.$whereStmt ;
$Result    = $MyDb->f_ExecuteSql($selectSql);
$Resultset = $MyDb->f_GetRecord($Result);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert into areas</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="scripts/pdw.js"></script>
<script type="text/javascript">
function checkForm(){
formErrors = new Array();



var errorText = '';
if (formErrors.length > 0){
for (var i=0; i<formErrors.length; i++)
errorText = errorText + formErrors[i] + '\n';
alert(errorText);
return false;
}

return true;
}
</script>

</head>
<body>
<form name="UpdateForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onSubmit="return checkForm()">
<div id="insertblock">
<table>
<tr>
  <td class="tableheader" colspan="2">Change Area of Service</td>
</tr>

<tr>
<th>Areaid:</th>
<td><input name="aboutid" type="text" id="aboutid_ID" value="<?php echo $Resultset['aboutid']; ?>" size="3" maxlength="5"></td>
</tr>
<tr>
<th>Area:</th>
<td><input name="about" type="text" id="about_ID" value="<?php echo $Resultset['about']; ?>" size="55" maxlength="255">

<textarea name="about" type="text" id="about_ID" value="<?php echo $Resultset['about']; ?>" wrap="hard" rows="7" cols="55">
<?php echo $Resultset['about']; ?>
</textarea> </td>
</tr>


<tr>
<?php
echo '<td class="tablefooter" colspan="2"><a href="javascript:history.back()"><img src="style/back.gif" alt="Back"></a>';
echo '<input type="image" src="style/update.gif" name="SubmitForm">';
?>
<input type="hidden" name="hidden_whereStmt" value='<?php echo $whereStmt; ?>'></td>
</tr>
</table>
</div>
</form>
</body>
</html>


<?php
}
else {
$updateSql = 'UPDATE about SET '
." aboutid='".addslashes($_POST['aboutid'])."'"
.", about='".addslashes($_POST['about'])."'"

.' WHERE '.stripslashes($_POST['hidden_whereStmt']);

$MyDb->f_ExecuteSql($updateSql);

header('Location: list.php');
}
?>

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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

</body>
</html>
<?php
}
else {
	$updateSql = 'UPDATE about SET '
			." aboutid='".addslashes($_POST['aboutid'])."'"
			.", about='".addslashes($_POST['about'])."'"
			.' WHERE '.stripslashes($_POST['hidden_whereStmt']);
	echo '<html>
		<head>
			<title>db update</title>
		</head>
		<body>
			<p><pre>', htmlentities($updateSql), '</pre></p>
			<a href="link.php">link.php</a>
		</body>
	</html>';
	flush();
		
	$MyDb->f_ExecuteSql($updateSql);

	
}
?>
it prints the update statement instead of the immediate redirection.
Are the values missing there just before "it will come back blank"?
stwallace
Forum Newbie
Posts: 3
Joined: Sat Oct 07, 2006 11:43 pm

Update code doesn't work with textarea

Post by stwallace »

Feyd,

I do apologize and will make sure future post reflect proper coding.

Volka,

I will try your code. The information actully shows in the textarea but when I click on the update its blank. However, the information shows in the address field of the browser at the top.

Thanks
Post Reply