Redirect not working going to $pid

I’m using a form to create posts, some of the code is below with the redirect. This is not redirecting to the newly created post it’s only refreshing the page with the form on it. Whats wrong with the redirect?