Hi,
I’m having trouble using forms to submit data to a mySQL database. I’m trying to do a simple insert. The data should go from the form’s fields to the database. There are four columns in the database (goal_id, goal_name, goal_text, & crs_name). The end result is that the table should be have a new goal_id auto-generated, the goal_name & goal_text, should come from the form, and finally value for crs_name should come from a php session variable. I’ve been digging through the documentation and support form trying to find the answer without success. Perhaps it’s some sort of logic error that I don’t understand.
I know for sure that I’ve initialized all dhtmlx components correctly so that’s not the problem. Any help you all could lend me will be greatly appreciated. The form is a simple two field form and a submit button. The code is below:
formStructure = [
{type:"settings",position:"label-top"},
{type: "fieldset",name:"fldstAddGoal", label: "Goals",
list:[
{type: 'input', name: 'goal_name', label: 'Goal Name:', validate: 'NotEmpty'},
{type: 'input', name: 'goal_input', label: "Goal Description:", rows: 15, validate: 'NotEmpty'},
{type:"button", name:"submtAddGoal", value:"Submit"}
]
}
];
var frmAddGoal = new dhtmlXForm("form_container", formStructure);
dpFrmAddGoal = new dataProcessor("../includes/dhtmlxSuite/dhtmlxConnector/codebase/form_connector.php");
dpFrmAddGoal.init(frmAddGoal);
tabbar.cells("a1").attachObject("form_container");
frmAddGoal.attachEvent("onButtonClick", function(id){
frmAddGoal.save("../control/addGoal.php");
});
The server side php code (addGoal.php) is as follows:
require("../includes/dhtmlxSuite/dhtmlxConnector/codebase/dataview_connector.php");
require("../includes/dhtmlxSuite/dhtmlxConnector/codebase/form_connector.php");
$conn = mysql_connect("localhost","root","root");
mysql_select_db("db_users");
//Connect to the database
$data = new DataViewConnector($conn, "MySQL"); // replaced $data = new DataViewConnector($conn);
// $data->enable_log("log.txt"); // create a log file
$data->render_table("tbl_goal", "goal_id", "goal_name,goal_text");//table name, ID, list of properties