Jump to content

PHP Redirect


gavin.sibley

Recommended Posts

Hello,

 

i am trying t set up a redirect depending on the username of the person. I am new to php so not exactly sure how to set it up. i have this so far, what is needed to make this work?

 

<?php

&user = GET_$user_login

header( 'Location: http://www.mydomain.com/[&user]-manager' ) ;

?>

 

thanks,gavin

Link to comment
Share on other sites

Where is the user name coming from? It *looks* like maybe you want:

 


$user = $_GET['user_login'];
header( "Location: http://www.mydomain.com/{$user}-manager" ) ;
exit();

 

This assumes that you are receiving the user_login from a GET request like

 

www.yoursite.com/thescriptabove.php?user_login=someuser

 

and it will redirect you to for example:

 

http://www.mydomain.com/someuser-manager

 

 

Link to comment
Share on other sites

What im trying to do is for each user to be redirected to there own homepage when they click the home page button, obviously there user_login is stored in the database so was hoping there was someway such as this to insert the user_login straight into a url redirector. doesnt seem to like the code above though, giving me a 404 error :(

Link to comment
Share on other sites

after looking around a bit (thank you google!) i have found this information that i think may help me, but as i said, having no idea about php really doesnt help!

 

?php global $current_user;

      get_currentuserinfo();

 

      echo 'Username: ' . $current_user->user_login . "\n";

      echo 'User email: ' . $current_user->user_email . "\n";

      echo 'User first name: ' . $current_user->user_firstname . "\n";

      echo 'User last name: ' . $current_user->user_lastname . "\n";

      echo 'User display name: ' . $current_user->display_name . "\n";

      echo 'User ID: ' . $current_user->ID . "\n";

?>

 

is there anyway of using this to do what im trying to do? to get the user_login?

 

thanks,

gavin

Link to comment
Share on other sites

You found that code from google?  How is that relevant to your code?  How does the user login? do you already have a script for that, which works? If so, there should be a session variable with the info for you to use, or else a session variable with an id associated to the user, for you to query your database for the user's name.  I'm starting to get the impression you have some 3rd party script you are trying to tweak...is this the case?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.