Forums

PHP

This topic is locked

phakt login problem

Posted 25 Oct 2001 15:50:07
1
has voted
25 Oct 2001 15:50:07 Bogdan bogdani posted:
I've installed Phakt extension for Ultradev 4, and i use a odbc connection to a mysql database. I tested the extension and it works fine, with one exception: I didn't succed in creating a login page.

This is my php generated page:
<?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/egate.php";
?><?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$KT_LoginAction = $PHP_SELF;
if ($QUERY_STRING!="" $KT_LoginAction .= "?".$QUERY_STRING;
if (isset($contxt)) {
$KT_valUsername=$contxt;
$KT_fldUserAuthorization="";
$KT_redirectLoginSuccess="index.htm";
$KT_redirectLoginFailed="about.htm";
$KT_rsUser_Source="SELECT cont, parola ";
if ($KT_fldUserAuthorization != "" $KT_rsUser_Source .= "," . $KT_fldUserAuthorization;
$KT_rsUser_Source .= " FROM egate WHERE cont='" . $KT_valUsername . "' AND parola='" . $paroltxt . "'";
$KT_rsUser=$egate->Execute($KT_rsUser_Source) or DIE($egate->ErrorMsg());
if (!$KT_rsUser->EOF) {
// username and password match - this is a valid user
$KT_Username=$KT_valUsername;
session_register("KT_Username";
if ($KT_fldUserAuthorization != "" {
$KT_UserAuthorization=$KT_rsUser->Fields($KT_fldUserAuthorization);
} else {
$KT_UserAuthorization="";
}
session_register("KT_UserAuthorization";
if (isset($accessdenied) && false) {
$KT_redirectLoginSuccess = $accessdenied;
}
$KT_rsUser->Close();
session_register("KT_login_failed";
$KT_login_failed = false;
header ("Location: $KT_redirectLoginSuccess";
exit;
}
$KT_rsUser->Close();
session_register("KT_login_failed";
$KT_login_failed = true;
header ("Location: $KT_redirectLoginFailed";
exit;
}
?>
<?php
$Recordset1=$egate->Execute("SELECT * FROM egate" or DIE($egate->ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1->RecordCount();
?>
<html>
<head>
<title>Login Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<table width="50%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<p>  </p>
<form name="form1" method="post" action="<?php echo $KT_LoginAction?>">
<p>
<input type="text" name="contxt">
<br>
<input type="text" name="paroltxt">
</p>
<p>
<input type="submit" name="Submit" value="Verifica">
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td bgcolor="#999999"> </td>
</tr>
</table>
</body>
</html>
<?php
$Recordset1->Close();
?>

The problem is that the login page seems to not verify the user name and the password in the database, because i'm not redirected to the failure page or succeded page.
This is the result from the session coockie:
KT_Username|s:4:"test";KT_UserAuthorization|s:0:"";KT_login_failed|b:0;

I tried also the 'Check new username' and it puts in database the values that i write in form, but when i type the same username (for example) to test it, i receive a "page not found" message exactly as when i tried to login.

What is the problem ?

Edited by - bogdani on 10/25/2001 18:14:01

Replies

Replied 25 Oct 2001 20:30:04
25 Oct 2001 20:30:04 Ryan Schwiebert replied:
I don't know If I can help here or not, so I'll just try. I have been using the login successfully on my website, though I am new to Phakt.

I'll use an example with the following assumtions: you have a database set up with a unique username column and a password column, and you do not wish to grant access based on Authorization Levels. (these are easily done too, so let me know if you need help with that)

Here's the procedure:
1. Create an access denied page.
2. Create a login success page of some sort.
3. On the login success page, and all other pages you wish to restrict access to: go to the Server Behaviors panel and choose User Authentication->Restrict access to page. In the dialog box, just select access based on username and password, and set the access denied page as the one you created in step 1.
4. Create a login page, insert a form and add two text fields, one for the username, and one for the password. Also add Submit and Reset buttons. (you also ought to name the fields so they make sense for the next step!) <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
5. On the login page, go to the Server Behaviors panel and choose User Authentication-&gt;Login User. Select your form and the username and password info. Fill in all of your connection info, the table with the coresponding username and password. Also fill in the pages to go to for access denied and the success page. Leave the bottom option set for just username and password.

That should work for you. So you know, the other User Authentication options are defined below:
<u>Logout User</u> is used on a link on the 'secure' pages to create a link that will kill the session (log them out)
<u>Check Username</u> is to be used on a page when a person is creating their own user account. It checks the table to see if the username is already being used. (you cant have more than one person with the same username!) <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>

Hope that helps.



Edited by - ryans on 10/25/2001 20:31:14

Reply to this topic