Hello:
I am using a dhtmlxform with a connector to load data in from a mySQL database, edit that record and save changes back to the database. I have the form being populated, that works great. However when I try to save the data back the connector adds a new record into the database instead of saving the changes that were made in the form.
Here is page that gets included on the populate forms page
<!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=iso-8859-1" />
<title><?php echo $applicationName; ?></title>
<link rel="stylesheet" type="text/css" href="/css/master.css">
<link rel="stylesheet" type="text/css" href="/css/table.css">
<link rel="stylesheet" type="text/css" href="/js/dhtmlxSuite2.6/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css">
<script src="/js/master.js" type="text/javascript" charset="iso-8859-1"></script>
<script src="/js/dhtmlxSuite2.6/dhtmlxForm/codebase/dhtmlxcommon.js"></script>
<script src="/js/dhtmlxSuite2.6/dhtmlxForm/codebase/dhtmlxform.js"></script>
<script src="/js/dhtmlxSuite2.6/dhtmlxForm/codebase/dhtmlxdataprocessor.js"></script>
<script src="/js/dhtmlxSuite2.6/dhtmlxForm/codebase/connector/connector.js"></script>
</head>
<body>
<?php
echo $pagemaincontent;
?>
</body>
</html>
Here is the code that I use to populate the form:
<?php
//Buffer larger content areas like the main page content
ob_start();
?>
<form action="" method="post" accept-charset="iso-8859-1" id="my_form">
<table class="FM_Table" width="100%;">
<caption>
Client
</caption>
<tr>
<td class="altbg">
First Name:</td>
<td>
<input bind="firstName" type="text" name="firstName" value=""></td>
</tr>
<tr>
<td class="altbg">
Last Name:</td>
<td>
<input bind="lastName" type="text" name="lastName" value=""></td>
</tr>
<tr>
<td class="altbg">
Phone Number:</td>
<td>
<input bind="phoneNumber" type="text" name="phoneNumber" value=""></td>
</tr>
<tr>
<td class="altbg">
Email:</td>
<td>
<input bind="eMail" type="text" name="eMail" value=""></td>
</tr>
<tr>
<td class="altbg">
Contract Signed:</td>
<td>
<input bind="contractSigned" type="checkbox" name="contractSigned"></td>
</tr>
<tr>
<td class="altbg">
Release Signed:</td>
<td>
<input bind="releaseSigned" type="checkbox" name="releaseSigned" ></td>
</tr>
<tr>
<td colspan="2" class="footer" align="right"><input type="image" name="updateForm" src="images/update.gif" onclick="dp.sendData(); false;">
<input type="image" name="cancelForm" src="images/cancel.gif" onClick="closeWindow();"></td>
</tr>
</table>
</form>
<script type="text/javascript" language="javascript">
var myForm = new dhtmlXForm("my_form");
myForm.load("connectors/clientForm.php?id=1");
var dp = new dataProcessor("connectors/clientForm.php");
dp.init(myForm);
</script>
<?php
//Assign all Page Specific variables
$pagemaincontent = ob_get_contents();
ob_end_clean();
//Apply the template
include("master/windowMaster.php");
?>
Here is my clientForm.php file:
<?php
require_once("../config.php");
$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);
require("../js/dhtmlxSuite2.6/dhtmlxConnector/codebase/form_connector.php");
$form = new FormConnector($res);
//$form->enable_log("log.txt");
$form->render_table("clients","clientID","firstName,lastName,phoneNumber,eMail,contractSigned,releaseSigned,insertDate,insertBy");
?>
Any help would be greatly appreciated! I must say that the connector works great to populate the form!