Can someone point out what I’m doing wrong and send me in the right direction. I’m having trouble submitting form data. Here’s the code from the client page:
<!DOCTYPE HTML>
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no">
<link rel="stylesheet" href="../includes/dhtmlxTouch/codebase/touchui.css" type="text/css" />
<script src="../includes/dhtmlxTouch/codebase/touchui.js" type="text/javascript"></script>
<link rel="stylesheet" href="../style/sonicboom.css" type="text/css" />
</head>
<body>
<script type="text/javascript" charset="utf-8">
dhx.ui(
{cols:[
{rows:[
{view:"form", width:400, id:"testform1", elements:[{view: "text", labelWidth:120, label: "Goal Name", name:"name"},
{view: "text", labelWidth:120, label: "Description", name:"text"},
{view: "text", labelWidth:120, label: "Content", name:"content"},
{view: "button", type:"form", label:"Save", click:"save_form"}
]},
{css:"areaA"}
]}
,
{css:"areaB", view:"dataview", id:"viewGoals", width:600, height:600,
xCount:2, yCount:5, type:{template: "<p class='bananna'><b>Goal Name </b>#name#
<b>Description</b>#text#
<b>Content</b>#content#</p>",
height:320, width:370}
}
]
}
);
var viewGoalsProcessor = new dhx.DataProcessor({
master:$$('viewGoals'),//specifies a linked datasource
url:"../control/retrofit.php"//defines the path to the file which will get change requests
});
$$('viewGoals').load();
$$('testform1').bind('viewGoals');
function save_form(){
var newRecord = {id:dhx.uid()};
$$('viewGoals').add(newRecord);
$$('testform1').save();
}
</script>
</body>
</html>
Now, Here’s the code from the server:
<?php
session_start();
require("../includes/dhtmlxConnector_php_v10/php/codebase/data_connector.php");
$conn = mysql_connect("localhost","root","");
mysql_select_db("db_users");
//Connect to the database
$dataCourse = new DataViewConnector($conn, "MySQL"); // replaced $data = new DataViewConnector($conn);
//$dataCourse->enable_log("logDataCourse1.txt", true); // create a log file
//$dataCourse->render_sql("SELECT * from courses where course='course 1'");
if ($dataCourse->is_select_mode()){
//code for loading data
$dataCourse->render_table("goal", "id", "name, text, content");//table name, ID, list of properties
}else{ //code for other operations - i.e. update/insert/delete
$dataCourse->render_table("goal", "id", "name, points, content");//table name, ID, list of properties
}
?>
If you execute the code above you will find that a new item is created in the dataview. However, it contains none of the data from the form.