0
我在一个预先制作的项目中使用oop php在mysql数据库中插入了一个表单数据。所有的工作都是正确的,但是在提交任何成功和失败的信息后都没有显示。 我的表格示例代码:在数据库中插入数据时在oop上输出的信息
performance.php->
<h1>Employee Review Form</h1>
<form name="product" action="" method="post" id="customForm">
<table>
<tr>
<td>Review Employee Id</td>
<td><input type="text" name="rcode" id="rcode" class="genInputBox" /></td>
</tr>
<tr>
<td>Domain Knowledge(Subject Matter)</td>
<td><select name="dk" id="dk">
<option value="">Plz Select Ratting </option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select></td>
</tr>and more...............
<input type="submit" value="register" id="submit" name="form_submit"/>
</td></tr>
</table>
</form>
和表单提交过程
<?php
if(isset($_POST) && isset ($_POST["form_submit"])){
$valArr=array("review_emp_id"=>$_POST['rcode'],"subject_matter"=>$_POST['dk']);
$per_obj = new Performance();
$per_obj->addPreformance($valArr, "employee_performance");
}
?>
和我的课堂表现页面是:
<?php
require_once("admin/includes/class_common_lib.php");
require_once("class.userinfo.inc.php");
class Performance extends DataAccess{
var $db_obj = null;
public function __construct() { //for database connectivity
$this->db_obj = new DataAccess();
}
public function addPreformance($key_values = array(), $table = null) {
$this->db_obj->table_name = $table;
$this->db_obj->addRecord($key_values);
}
}
?>
和类通用库增加记录功能代码是:
// Function for Add Record
function addRecord($key_values)
{
$cols="";
$vals="";
foreach($key_values as $key=>$value)
{
if ($key!="submit" and $key!="PHPSESSID" and $key!="image_name" and $key!="submit_button" and $key!="ext" and $key!="ext2" and $key!="img_name" and $key!="mode" and $value!="" and $key!="gpl" and $key!="ip1" and $key!="ip2" and $key!="ip3" and $key!="ip4"){
$cols .= "`".$key."`,";
is_string($value)? $vals .= "'".addslashes($value)."'," : $vals .= "'".$value."',";
}
}
$cols = substr($cols, 0, -1);
$vals = substr($vals, 0, -1);
$insert_qry="insert into ". $this->table_name ."(". $cols .") values(". $vals .")";
$r=mysql_query($insert_qry);
$this->msg = (!$r) ? f_add_msg : s_add_msg;
return $r;
}
它是一个非常大的项目,我完成了其他人以前完成的所有过程。
现在我想显示msz数据在提交表单后是否在数据库中提交(成功或失败)。
,我发现在配置文件中
define ("s_add_msg", "Record successfully added.");
define ("f_add_msg", "Record not added. Please try again.&error=1");
我知道它的冗长的代码,但我需要显示会发生什么,这些线。 所有功能工作正常,但 我怎么能显示performance.php页成功或失败的消息?请帮
很难从您提供的代码示例中发现错误。相关状态消息正在db对象中设置,但在调用addPerformance之后没有代码来告诉如何检索该消息。 – liquorvicar
是的,先生,我告诉过,这是一个双重和预先制定的项目,我只做了一些更正 – ravinath