prepare("INSERT INTO pastes (title,text) VALUES (:tit, :txt)"); $stmt->bindParam(':tit', $title); $stmt->bindParam(':txt', $text); $stmt->execute(); $id = $conn->lastInsertId(); $conn = null; //close connection to database header("Location: ".$id); die(); } } $conn = null; ?>