Zubrag.com
August 20, 2018, 10:44:55 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Awesome script but I have a small problem with redirect not working.  (Read 9037 times)
thejanbalster
Newbie
*
Posts: 3


« on: November 27, 2007, 07:38:39 AM »

Hey Zubrag,

I love the script, it's exactly what I was looking for. The internet is such an amazing invention and it's wonderful how we use it to share the things that we have created.

Anyway, I got the script to work for the most part. My only problem is that the redirect doesn't seem to work. Here is what I've done so far:

- updated settings.php file
- uploaded the entire package
- set the permissions for users.php
- generated the protection string
- created a php page with the protection string in it and called it abc_xyz.php

When I navigate to abc_xyz.php the login page will appear and, since I set define('USE_USERNAME', false); it will only offer me one input field. When I enter a user's password I get an "incorrect password" return. When I enter the username I'm let through and the content of my abc_xyz.php page appears, which only says "Redirecting". The plan was to take the before-mentioned steps but to then be redirected to a page defined for each individual user. User1 redirect to www.user1.com, User2 redirect to www.user2.com etc.

I set the define('REDIRECT_PREFIX', 'http://domain.net/'); and in the manager.php I set the redirect as a directory i.e. folder/ so the whole string should be http://domain.net/folder/
The redirect prefix does not appear in the manager.php page.

Well, this is all I can think of to explain my situation.

Thanks in advance for the help.

- Jan

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: November 27, 2007, 08:07:30 AM »

Hi Jan!

Redirects and signup can only work if you use usernames, i.e. define('USE_USERNAME', true);  Well, i'm not even sure why i did not remove "passwords only" code from the script.
We cannot redirect based on passwords because few users potentially could use the same password. Could you use usernames?

"The redirect prefix does not appear in the manager.php page" is ok. Program ads prefix on the fly, when redirecting.
Logged
thejanbalster
Newbie
*
Posts: 3


« Reply #2 on: November 29, 2007, 09:06:54 AM »

Hey Zubrag,

Thanks for the help, it's working great now. Couple of questions, though. First, I'm not going to have people sign up, so there wouldn't be a problem with two users having the same password. Would it be possible to have the "user name only" i.e ('USE_USERNAME', false); and still get the redirect?

The other thing is, and I know this might not be your area of expertise but never hurts to ask, would you have any suggestion how to embed the login form into a Flash website?

Thanks again for your help and the extremely fast response.

- Jan
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #3 on: November 29, 2007, 10:28:18 AM »

Jan

in login.php, find this code
Code:
    // need to be redirected?
    if (isset($REDIRECTS[$login]) && !empty($REDIRECTS[$login])) {
      header('Location: '
             . ((REDIRECT_PREFIX != '') && (strpos($REDIRECTS[$login], 'http') !== false) ? '' : REDIRECT_PREFIX)
             . $REDIRECTS[$login]);
      exit();
    }

and replace all the $login with $pass in that block

Than find
Code:
  else {
    $LOGIN_INFORMATION[] = trim($u[0]);
  }

and replace with
Code:
  else {
    $LOGIN_INFORMATION[] = trim($u[0]);
    $REDIRECTS[trim($u[0])] = isset($u[3]) ? trim($u[3]) : '';
  }
Logged
thejanbalster
Newbie
*
Posts: 3


« Reply #4 on: December 05, 2007, 09:47:05 AM »

Hey Zubrag,

That was great it is working like a charm. Last thing now, what would I have to send from Flash (ActionScript) to the PHP form to bypass the login form.

What I really want is for the user to type in "User1" in an input field on my Flash page, ActionScript sends that information to the appropriate PHP script and, if the info is correct, the user is redirected to the pre-determined URL for User1. If the input is incorrect the script echos the error and ActionScript displays it in the dynamic text field "tError".

Here is an example of the ActionScript that I'm using.


tUsername.setFocus();

tError.autoSize = "right";

var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

submitBtn.onRelease = function() {
   lvSend.username = tUsername.text;
   lvSend.password = tPassword.text;
   lvSend.sendAndLoad("logincheck.php", lvReceive, "POST");
};

lvReceive.onLoad = function(success:Boolean) {
   if (success) {
      if (this.login == "success") {
         getURL("members.php");
      }else{
      tError.text = "I'm sorry you did not enter valid login details";
      }
   } else {
      trace("no reponse from server");
   }
};
 
stop();


I know I'm asking a lot here but I'm just at a loss as how to make this work. Your script is perfect for what I need with the only drawback of not fitting into m design, since it is in Flash.

Thanks again and I really appreciate your help.

- Jan
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #5 on: December 06, 2007, 10:18:00 AM »

Jen

In login.php replace all the references to $_POST with $_REQUEST

When done, you should be able to login passing username and password via URL. Like this:

http://www.example.com/members/protected-page.php?access_login=login&access_password=password

If you want to handle errors in your script, find this code
Code:
function showLoginPasswordProtect($error_msg) {
  include('login_header.php');
  include('login_form.php');
  include('login_footer.php');

  // stop at this point
  die();
}

and replace with
Code:
function showLoginPasswordProtect($error_msg) {
  // stop at this point
  die("ERROR: " . $error_msg);
}

After these changes script will return string "ERROR: error text here", which you could parse in your script.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC