March 16, 2012

Redirect Page after Login

Question by Dom

I have user login page on my site that currently uses the following code to redirect users to this page – index.php

// Redirect to frontpage
                        header("Location: index.php");
                }

But I would like to redirect the user to this page: books.php

books.php?u='.$_SESSION['uid'].'

I tried

header("Location: books.php?u='.$_SESSION['uid'].'"); 

But that doesn’t work – I assume that I am missing some ‘ or brackets. Can anyone suggest some help.

Answer by Starx

There is a typo error in your code.

header("Location: books.php?u=".$_SESSION['uid']); 
//                            ^ missing matching quote and extra quote at the end
exit(); // As Bazzz said, you should stop the processing after this

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!