我在Dreamweaver中创建了一个评论框,一切正常..但是当我点击提交时,当我去phpmyadmin时,数据没有显示在那里..谢谢你的帮助伙伴..我是新的PHP ..
这是我的代码html + php
<?php require_once('Connections/Comment.php'); ?>
<?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"] == "comment")) {
$insertSQL = sprintf("INSERT INTO ``comment`` (name, `comment`) VALUES (%s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['comment'], "text"));
mysql_select_db($database_Comment, $Comment);
$Result1 = mysql_query($insertSQL, $Comment) or die(mysql_error());
$insertGoTo = "access_denied.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_Comment, $Comment);
$query_User_Comment = "SELECT * FROM `comment`";
$User_Comment = mysql_query($query_User_Comment, $Comment) or die(mysql_error());
$row_User_Comment = mysql_fetch_assoc($User_Comment);
$totalRows_User_Comment = mysql_num_rows($User_Comment);
$query_User_Comment = "SELECT * FROM `comment`";
$User_Comment = mysql_query($query_User_Comment, $Comment) or die(mysql_error());
$row_User_Comment = mysql_fetch_assoc($User_Comment);
$totalRows_User_Comment = mysql_num_rows($User_Comment);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Comment</title>
<link href="jquery-mobile/MyTheme.css" rel="stylesheet" type="text/css">
<link href="jquery-mobile/jquery.mobile.structure-1.3.0.min.css" rel="stylesheet" type="text/css">
<script src="jquery-mobile/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.3.0.min.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header">
<h1>Comment</h1>
</div>
<div data-role="content">
<form method="POST" action="<?php echo $editFormAction; ?>" name="comment">
<label>Name: </label>
<input name="name" type="text" autofocus required>
<label>Comment: </label>
<input name="comment" type="text" required>
<input type="submit" value="Submit">
<input type="hidden" name="MM_insert" value="comment">
</form>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($User_Comment);
?>