This topic is locked
[SOLVED]

  Auto Login via URL

4/17/2012 10:54:04 AM
PHPRunner General questions
C
copper21 author

Hello,
I am looking to send an email that contains the url to a list page in my project; that is the easy part. Now within that link, I would like to be able also pass the username and password of the receiver so that they do not have to log in, but just go directly to that list page. I have looked at the post: http://www.asprunner.com/forums/topic/13347-auto-login/ , but this does not explain what the url is supposted to be or look like. I have tried http://servername/projectname/login.php?username=admin&password=123456 and even then this only fills in the username field, but does not fill in the password field and does not auto login.
My user table name is users, and the username field is "username" and "password" is the password field.
PHP Runner 6.0, MSSQL
Thanks in advance.
Brian

admin 4/17/2012

Your URL is correct, most probably there is an issue with your code that processes username and password.
Besides that, instead of login.php you need to use the URL of the page where you want user to go. The idea is to avoid the login page all together.

C
copper21 author 4/17/2012

Sergey,
Thank you for the response. I am getting a message stating that the session has timed out on the login page after going to the url with the username and password in it. Here is what I have in Login Page: Before Process:
global $dal;
if (@$_REQUEST["username"] && @$_REQUEST["password"])

{
//select record from database
$rstmp = $dal->UsersTablename->Query("username='".$_REQUEST["username"]."' and password='".$_REQUEST["password"]."'","");
if ($datatmp = db_fetch_array($rstmp))
{
$_SESSION["UserID"] = $_REQUEST["username"];
header("Location: Pending_Requests_list.php");exit();
}}
and this is the url I am using:
http://servername/projectname/pending_requests_list.php?username=admin&password=MD5password.
My passwords are encrypted using MD5 in the database table. I have used both the MD5 and plain text for passwords in the url.
Thanks,

admin 4/17/2012

This code needs to be added to Pending_Requests_list.php BeforeProcess event. UsersTablename needs to be replaced with login table name. Redirect to Pending_Requests_list.php is not required since you are already on this page.
If you need more help 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.

C
copper21 author 4/17/2012

Finally got it. I had to change a few things as the code I was using I think was from older versions of PHPRunner. Here is what worked for me using PHP Runner 6.0:

//auto login via url
global $dal;
if (@$_REQUEST["username"] && @$_REQUEST["password"])
{
//select record from database
$usertable = $dal->Table("users");
$rstmp = $usertable->Query("username='".$_REQUEST["username"]."' AND password='".$_REQUEST["password"]."'","");
if ($datatmp = db_fetch_array($rstmp))
{
$_SESSION["UserID"] = $_REQUEST["username"];
}};


Sergey, thanks for showing me the right direction!
Brian