This topic is locked
[SOLVED]

 Autologin via URL

6/27/2012 11:41:43 AM
PHPRunner General questions
S
snuffi01 author

I'm trying to follow this post http://www.asprunner.com/forums/topic/19407-auto-login-via-url/
My login table name is:customer

In that table the usenamefield is:Customer_UserName AND Password field:Customer_Password
At the listpage in witch i want to be able to login via URL i have added this code at "List page:Before process"

//auto login via URL
global $dal;
if (@$_REQUEST["username"] && @$_REQUEST["password"])
{
//select record from database
$usertable = $dal->Table("customer");
$rstmp = $usertable->Query("Customer_UserName='".$_REQUEST["username"]."' AND Customer_Password='".$_REQUEST["password"]."'","");
if ($datatmp = db_fetch_array($rstmp))
{
$_SESSION["UserID"] = $_REQUEST["username"];
}};
My URL for the auto login is: http://servername/ListPageExample.php?username=TestUser&password=testpassword01
But the result is always that i get redirected to the login page....
My Database is Mysql, i'm using PhpRunner 6.1
/ Regards Kristian

Admin 6/27/2012

Make sure table and field names are correct. Make sure that this user has permissions to access the List page in question.
If you have a valid support contract 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.

S
snuffi01 author 6/27/2012



Make sure table and field names are correct. Make sure that this user has permissions to access the List page in question.
If you have a valid support contract 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.


I have no valid support contract <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=66795&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
The Table and filed names are correct.

Tried to make an new project where i only have one table, i set the security the same way.

I firts login with an valid username and password to see that it works and it does, then i logout and tries the url with username and password.

Then i alwayes gets redirekted to th elogin page with the message Your session has expired. Please login again.
/ Kristian

C
cgphp 6/27/2012

Put the code in the "After table initilized" event of the customer table.

If you hash password in the db, your code should be:

global $dal;
if(@$_REQUEST["username"] && @$_REQUEST["password"])

{

//select record from database
$usertable = $dal->Table("customer");
$rstmp = $usertable->Query("Customer_UserName='".$_REQUEST["username"]."' AND Customer_Password='".md5($_REQUEST["password"])."'","");
if($datatmp = db_fetch_array($rstmp))

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

}

}
S
snuffi01 author 6/28/2012



Put the code in the "After table initilized" event of the customer table.

If you hash password in the db, your code should be:

global $dal;
if(@$_REQUEST["username"] && @$_REQUEST["password"])

{

//select record from database
$usertable = $dal->Table("customer");
$rstmp = $usertable->Query("Customer_UserName='".$_REQUEST["username"]."' AND Customer_Password='".md5($_REQUEST["password"])."'","");
if($datatmp = db_fetch_array($rstmp))

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

}

}



Thanks!
The trick is to put the code "After table initilized" of the listpage you want to be able to login via url
/ Kristian