This topic is locked

Question about login

3/23/2012 11:08:13
PHPRunner General questions
L
lordkain2 author

I have to connect to a BD (MS SQL Server) that has a password field type "CHAR" (fixed size), how can I use RTRIM function before login?

Sergey Kornilov admin 3/23/2012

The best and only approach is to fully override PHPRunner login procedure in BeforeLogin event.
If authentication is successful populate required session variables and then redirect user to the start page of your application. Here is the sample code that populates session variables and redirects user (assuming that you use BeforeLogin event):

$_SESSION["UserID"] = $username;

$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;

header("Location: menu.php");

exit();
500509 3/23/2012

I have this code to have a link go through the login straight to the view page It works fine for the users table

but I would like to use it with the table Plan Holders and username = email and password = Company



if (@$_REQUEST["record"])

$_SESSION["record"] = $_REQUEST["record"];
global $dal;

if (@$_REQUEST["users"] && @$_REQUEST["username"] && @$_REQUEST["password"]

&& @$_REQUEST["editid1"])

{

//check if user exists in the database

$dal_table = $dal->Table("users");

$rstmp = $dal_table->Query("username='".$_REQUEST["username"]."' and

password='".$_REQUEST["password"]."'","");

if ($datatmp = db_fetch_array($rstmp));

{

//fill session variable

$_SESSION["UserID"] = $_REQUEST["username"];

$_SESSION["_projects_OwnerID"] = $datatmp["Company"];

$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;

//redirect to another page

header("Location: projects_view.php?editid1=".$_REQUEST["editid1"]);

exit();

}

}


I've tried a bunch of different combinations and I can't make it work any help would be appreciated.

Sergey Kornilov admin 3/23/2012

@wbdesigner,
if you need help making it work post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

L
lordkain2 author 3/25/2012

Sorry, I didn't explain well my point, the password field is 'CHAR' type (has fixed size and complete the remain size with ' '.

Example: if I type '123456' and the size of the field is 10, the password store in the db is: '123456 '.
I can't change the field, is there a way to trim the space at the end of the field, before PHPRunner compare the type password with the database password? I know there's the BEFORE LOGIN event but not what to do.
Thanks.

C
cgphp 3/25/2012

In the "Before login" event, enter this code:

$password = substr($password,1,6);