Insert Record not doing anything
hello,
i'm trying follow along tutorial making dynamic websites:
http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt2.html
i've done part 1 , going smoothly until trying set add post functionality. database working pulling information in manage posts page , when add insert record server behavior, looks fine hitting "post it!" button nothing in live view or in browser preview. doesn't add record nor redirect manage_posts.php link. nothing when i'm holding cmd click (i'm using mac). other links work fine.
i can add record manually in phpmyadmin , have display correctly in live view of manage_posts page.
i'm using mac running snow leapord , using creative cloud dreamweaver cs6. using mamp local server , phpmyadmin, specified in first part of tutorial.
code copied below:
<?php require_once('../connections/check_mag.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"] == "form1")) {
$insertsql = sprintf("insert news (title, blog_entry) values (%s, %s)",
getsqlvaluestring($_post['title'], "text"),
getsqlvaluestring($_post['blog_entry'], "text"));
mysql_select_db($database_check_mag, $check_mag);
$result1 = mysql_query($insertsql, $check_mag) or die(mysql_error());
$insertgoto = "manage_posts.php";
if (isset($_server['query_string'])) {
$insertgoto .= (strpos($insertgoto, '?')) ? "&" : "?";
$insertgoto .= $_server['query_string'];
}
header(sprintf("location: %s", $insertgoto));
}
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>add post</title>
<link href="../styles/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>what's buzz?</h1>
<p><a href="index.php">admin menu</a></p>
<form action="<?php echo $editformaction; ?>" id="form1" name="form1" method="post">
<p>
<label for="title">title: </label><input name="title" type="text" class="textfields" id="title" maxlength="150" />
</p>
<p><label for="blog_entry">post: </label>
<textarea name="blog_entry" cols="45" rows="5" id="blog_entry" form="form1"></textarea>
</p>
<p>
<input name="button" type="button" id="button" form="form1" value="post it!" />
</p>
<input type="hidden" name="mm_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
what seem missing here? appreciated.
your "post it!" button, not submit button. change type="submit" , see if works.
^_^
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment