0

I have a login page that contains a variable $blogid which "gets" the blog id number from a previous page. the code is $blogid = strip_tags(htmlentities(stripslashes($_GET['blog']))); After a user logs in I need to pass the user id and blog id to another page (comments_post.php) I have the following code

        $_SESSION['user'] = $userrow[0];
        $_SESSION['pass'] = $userpass;

        die(header("Location: comments_post.php?blog=1&user=$userrow[0]"));

The redirect passes the blog id as 1 and the correct user id number (from a table). I need the statement to pass the blog id number that is defined by $blogid. if I change the code to blog=$blogid only the user id is passed. How do I get the $blogid variable to pass to comments_post.php?

1 Answer 1

4

How about

die(header('Location: comments_post.php?blog=' . $blogid . '&user= ' . $userrow[0]));

Also are you sure $blogid is defined?

Sign up to request clarification or add additional context in comments.

11 Comments

10 yrs of PHP programming and putting exit() after header redirects only now to realize from your answer it would have made more sense to put the redirect inside it. I'd give +50 if I could, but +1 it is! =o)
Yes $blogid is defined. if I echo $blogid on the page, I can see the correct blog id number.
I tried your format. When I see the comment post page, the blog id and user id numbers appear at the bottom (like 4 15). The first number being the blog id. This is what I got ' . . ' ' . 15
I tried '$blogid' as well and got basically the same results ' ' 15
@learner what's in the URL on the page you have redirected to?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.