我正在使用dreamweaver cs4“插入”功能来管理单个页面上的多个表单。但我编辑代码时遇到困难:
这是Dreamweaver到目前为止给我的内容......它应该只向数据库添加一个新行(未经测试):
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO tbl_solicitors (solicitorName, solicitorDetail) VALUES (%s, %s)",
GetSQLValueString($_POST['solicitorName'], "text"),
GetSQLValueString($_POST['solicitorDetail'], "text"));
mysql_select_db($database_speedycms, $speedycms);
$Result1 = mysql_query($insertSQL, $speedycms) or die(mysql_error());
}
?>
任何帮助将不胜感激...谢谢,新年快乐!
答案 0 :(得分:0)
不要担心我找到了解决方案......决定不使用我不熟悉的代码!
感谢您查看!
if (array_key_exists('solicitor',$_POST)) {
$solicitorName = $_POST['solicitorName'];
echo "The record for <b>$solicitorName</b> has been successfully added to the database.<p>
<a href='#' class='form'>View details</a><p>
<a href='instructus.php' class='form'>Create a new record</a>
";
exit;
};