所以我基本上做的是我想在插入功能之后立即将用户重定向到art.php?id=$id
,例如:
所以这是我的$user->insertArt
函数:
public function insertArt($description,$image,$creator,$width,$height){
try {
$sql = "INSERT into arts (description,id,image,creator,post_date,width,height) values (:description,UUID_SHORT(),:image,:creator,NOW(),:width,:height)";
$stmt = $this->con->prepare($sql);
$stmt->bindValue(':description',$description,PDO::PARAM_STR);
$stmt->bindValue(':image',$image,PDO::PARAM_STR);
$stmt->bindValue(':creator',$creator,PDO::PARAM_STR);
$stmt->bindValue(':width' , $width, PDO::PARAM_INT);
$stmt->bindValue(':height' , $height, PDO::PARAM_INT);
$stmt->execute();
return true;
}catch(PDOException $e){echo $e->errorInfo; return false;}
}
所以我正在尝试做的就像下面一样,用$id
取代$user->in
来获取if ($user->insertArt($description, $image['url'], $creator, $width, $height)) {
unlink(realpath('uploads/' . $newFileName));
//redirect user to the ID.
header("Location:art.php?id=$id"); // replace $id with UUID_SHORT from the query
}
}
的id行。
json api plugin