Jump to content

[SOLVED] How to load specific url on log on


scottreid1974

Recommended Posts

Hi

I want to be able to have a user log on and then have a website automatically open that is specific to them, (one i have attached to their user name and password in a mysql database). I have ID, password, username,url stored in database rows.

All I can do at the minute is a normal logon script which automatically takes all accounts to the same page after logon-on.

For example, when user fred12, password - werryu logs on, i want to send him to www.yahoo.co.uk, and when user jane34, password - aserwg logs on, i want to send her to www.yell.com, and so on.

I cant get the forwarding bit of the logon to work.

Thanks

Scott
Link to comment
Share on other sites

I did find a tutorial on array's, however it does not make alot of sense,
I actually tried an array before with no success. I tried

$record = array('userID, 'username', password, 'access', 'url');

record = mysql_fetch_array($loginFoundUser);

the header part of the code was nonsense totally, hence why i'm stuck.

Do I retrieve the url specific to that logon name and password in an array, and how do i save it as seperate variable?, to recall in the header you showed above.


Thanks
Link to comment
Share on other sites

Again, if Iv misunderstood the question I apologise, otherwise:-

Do your login check etc..

If login is correct then:-

[code]header("Location: ".$row['url']);[/code]

If the login is correct then it will redirect that user to the URL which is stored in their field of the database.



Link to comment
Share on other sites

hi, thanks for help, but it dosent seam to work, here is my code, could u tell me whats wrong?



<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "access";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_testconn1, $testconn1);
 
  $LoginRS__query=sprintf("SELECT username, password, url, access FROM users WHERE username=%s AND password=%s",
  GetSQLValueString($loginUsername, "text"),GetSQLValueString($url, "text"), GetSQLValueString($password, "text"));
 
  $LoginRS = mysql_query($LoginRS__query, $testconn1) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
 
 

$loginStrGroup = mysql_result ($LoginRS,0,'access');



    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;


    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
  header("Location: ".$row['url']);
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
Link to comment
Share on other sites


Sorry to be a pain, i have tried adapting the tutorial to my table and icant gfet it to work


<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "access";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_testconn1, $testconn1);
 
  $LoginRS__query=sprintf("SELECT username, password, url, access FROM users WHERE username=%s AND password=%s",
  GetSQLValueString($loginUsername, "text"),GetSQLValueString($url, "text"), GetSQLValueString($password, "text"));
 
  $LoginRS = mysql_query($LoginRS__query, $testconn1) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
 
 

$loginStrGroup = mysql_result ($LoginRS,0,'access');

$sql = "select url from users";
while ($list = mysql_fetch_array($LoginRS))


    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;


    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
  header('Location: '.$sqlURL);
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
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.