Hooch Posted April 25, 2006 Share Posted April 25, 2006 I have a login.php page that will say you have successfully logged in or it will say try again if something is wrong. I wish to change the successfull login from this.. // set a cookiesetcookie( "id", "$id", time()+3600, "/", "", 0 );echo "User Logged in.<br><br><a href=\"index.php\">Continue...</a>";} To redirecting back to index.php automatically. Can I do this, If so how? Thank you..Hooch Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted April 25, 2006 Share Posted April 25, 2006 here you go: print "<script>location = 'index.php';</script>"; Link to comment Share on other sites More sharing options...
Hooch Posted April 25, 2006 Author Share Posted April 25, 2006 Like a glove!! Thanks man! Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 25, 2006 Share Posted April 25, 2006 I suggest you also add this:print '<noscript><a href=\"index.php\">Click here to go back to index.php</a></noscript>';As some browsers don't support javascript. Link to comment Share on other sites More sharing options...
Hooch Posted April 25, 2006 Author Share Posted April 25, 2006 Hi Chocolate,would it look like this then? // set a cookiesetcookie( "id", "$id", time()+3600, "/", "", 0 );print "<script>location = 'index.php';</script>"; print '<noscript><a href=\"index.php\">Click here to go back to index.php</a></noscript>';} Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 25, 2006 Share Posted April 25, 2006 Yup, except I don't know why you have an extra bracket at the end. Is that just part of your main script? If so, that should work. You could remove those \'s behind the quotes, though. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 25, 2006 Share Posted April 25, 2006 You can also just add a header to instruct the browser to redirect (not through javascript): header("Location: index.php"); This will only work if you haven't started the page output yet, but if you are setting a cookie then headers are still being sent, so it should work here. Link to comment Share on other sites More sharing options...
Hooch Posted April 26, 2006 Author Share Posted April 26, 2006 Thanks guys. I took Choclates advice and all is working. Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted April 26, 2006 Share Posted April 26, 2006 Good php has ' ' and " " and \' \' and \" \"... one time I like need 4 different quotes because I had a dynamic button input code thing, with php writing html with js links writing html that had php variables in it... Link to comment Share on other sites More sharing options...
LittleNicky Posted August 10, 2006 Share Posted August 10, 2006 So what would you put if you wanted to redirect to the page you were on before you logged in? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 10, 2006 Share Posted August 10, 2006 If you clicked on a link to get to the login page, then you would redirect to the referer. The referer for a page is the page where you clicked on a link to reach the current page. I believe that is in $_SERVER['HTTP_REFERER'] Link to comment Share on other sites More sharing options...
reportingsjr Posted August 10, 2006 Share Posted August 10, 2006 dont forget<meta http-equiv="refresh" url="0;http://domain.com/page.php" /> Link to comment Share on other sites More sharing options...
LittleNicky Posted August 10, 2006 Share Posted August 10, 2006 If you clicked on a link to get to the login page, then you would redirect to the referer. The referer for a page is the page where you clicked on a link to reach the current page. I believe that is in $_SERVER['HTTP_REFERER']OK cool, so would the code be header(Location: $_SERVER['HTTP_REFERER']); ? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 10, 2006 Share Posted August 10, 2006 Right, but you need quotes around it:header("Location: {$_SERVER['HTTP_REFERER']}"); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now