我的PHP代码有问题。 insert into..
查询不起作用,但未显示连接错误。似乎函数永远不会被调用。我做错了什么?
function addGroup(){
require_once('config.php');
$gid=mysql_real_escape_string($_POST['gid']);
$sql_add_group="INSERT INTO groups(gid) VALUES(".$gid.");";
$result = mysql_query($sql_add_group, $link);
if (! $result) {
die('Could not get data: ' . mysql_error());
}
mysql_close($link);
}
if(isset($_POST['Add Group'])){
addGroup();
}
if($_SESSION['type']=='professor'){
echo $_POST['gid'];
echo('<div>
<form action="groups.php" method="POST">
<label>Add/Remove Group<input class = "form-control" type = "text" name = "gid" id = "gid" placeholder = "group#"/></label>
<input id="button" type="submit" value="Add Group" name="Add Group"> </input>
<input id="button" type="submit" value="Remove Group" name="Remove Group"> </input>
</form>
</div><br/>');
}