Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > session

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-04, 04:06
smeeta smeeta is offline
Registered User
 
Join Date: Oct 2004
Posts: 14
session

i am trying to make a page to authenticate username and login in php. i know it can be done with session but am not able to figure it out. do i need to write a separate .php file and call it in the other .html file or i need to do something else.can anybody please help me out?
Reply With Quote
  #2 (permalink)  
Old 10-07-04, 11:14
rajesh_r_r rajesh_r_r is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 168
Let me ask you one thing. Are you tring to authenticate a html file or a php file?
If it's a php file then it can be simply done by sessions but if it is a html file then you may try it with iframes. I am not sure if it will work. Else you have to parse the html file through php. This can be done in apache.
I would suggest you to try the iframe method.

Regards
Rajesh
__________________
Freelance and Technology Consultant
-------------------
Dreams are for ever
-------------------
Reply With Quote
  #3 (permalink)  
Old 10-08-04, 01:03
smeeta smeeta is offline
Registered User
 
Join Date: Oct 2004
Posts: 14
login authentication

thanks for your suggestion Rajesh r r

actually my problem goes this way

i created a login page that is html page and made a connection to access
database through php using adodb.

the login page is displayed by the url lets say www.login.com and when
when i type the correct password it takes me to say
www.login.com/page1.html and when incorrect password is given it doesnot
grant the access to the desired page. it works fine till this.
now the problem is when i directly give url www.login.com/page1.html in the
address bar i get the access to the page. so the login page is of no use now.
one can directly access my private without login. so how can solve this problem.

smeeta
Reply With Quote
  #4 (permalink)  
Old 10-08-04, 02:48
rajesh_r_r rajesh_r_r is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 168
So you want to authenticate a html page. I woul suggest you to use iframe in the html page.
In page1.html use iframe in the top. I hope you know what an iframe is. Let the iframe contain the php code that check for login.
if you are using sessions then you could use like this
$username=$HTTP_SESSION_VARS['username'];
if($username=='')
{
header("Location: invalid_login.html");
}
This is just an idea to validate the login in the html file. Now some times (am not sure) this will only change the page in the iframe. In that case you have to use a javascript to change the url of the parent window.

Regards
Rajesh
__________________
Freelance and Technology Consultant
-------------------
Dreams are for ever
-------------------
Reply With Quote
  #5 (permalink)  
Old 10-13-04, 02:06
smeeta smeeta is offline
Registered User
 
Join Date: Oct 2004
Posts: 14
hi Rajesh r r

i donno about iframe and i am also new to php so really having problem with it!!
i tried your idea using session..but it desnot work....may be i did it the wrong way...can u pls explain it more briefly!!! i would be really be helpful

smeeta
Reply With Quote
  #6 (permalink)  
Old 10-13-04, 05:29
rajesh_r_r rajesh_r_r is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 168
Hi Smeeta
You have two option either you can use session cookies or just session variables. I would suggest to use session cookies.
<?php
$username=$HTTP_POST_VARS['username'];
//alfter login validation

setcookie ("username", $username); // this will set a cookie without any expiry time. means it will exprie when your session expires or your browser closes.

// this is the code that you have to include in the login validation page.
?>
Now in the after login page you have to include an iframe
<IFRAME SRC="auth.php" HEIGHT="5"></IFRAME>
Let say the file is auth.php
Now in auth.php page you have check for the cookie
this would be like this.
<?php
$username=$HTTP_COOKIE_VARS['username'];
f($username=='')
{
header("Location: invalid_login.html");
}
?>
If this doesnot change the entire page then you would have to user a javascript to change the location of the parent window.

Hope that you got some idea.

Regards
Rajesh
__________________
Freelance and Technology Consultant
-------------------
Dreams are for ever
-------------------
Reply With Quote
  #7 (permalink)  
Old 10-26-04, 04:06
smeeta smeeta is offline
Registered User
 
Join Date: Oct 2004
Posts: 14
oops!! this doesnot work out.
dont we need to write the code session_start(); any where?can u help me??

smeeta
Reply With Quote
  #8 (permalink)  
Old 10-26-04, 10:29
rajesh_r_r rajesh_r_r is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 168
session_start() is required only if you are using sessions to store and retrive the user infromation.
Let me find another way to do this.
Rajesh
__________________
Freelance and Technology Consultant
-------------------
Dreams are for ever
-------------------
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On