diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 5401d60b55..d251f2043c 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -1154,8 +1154,8 @@ func NewIssuePost(ctx *context.Context) {
 	}
 
 	log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
-	if ctx.FormString("redirect_after_creation") == "project" {
-		ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + strconv.FormatInt(form.ProjectID, 10))
+	if ctx.FormString("redirect_after_creation") == "project" && projectID > 0 {
+		ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + strconv.FormatInt(projectID, 10))
 	} else {
 		ctx.Redirect(issue.Link())
 	}