Connecting Tech Pros Worldwide Forums | Help | Site Map

how to Share variables among php and html

Newbie
 
Join Date: May 2009
Posts: 3
#1: May 11 '09
Hi Experts,
I have created a login page in php called login.php, it accepts username, password and domain and then does some authentication. IF authentication succeeds it starts a php session and sets a session attribute. In my php application, i check this session attribute in all the pages to find out whether the user has logged in or not.

Now I have another application entirely written in html. Now I want to call this login.php page when a user tries to access any html page. Now the problem is ,I can call the login.php page using a simple javascript call but once the user enters the credentials and gets authenticated how will I pass the knowledge to the html page that the session variable is created, because if the html page does not recognize the creation of php session variable, it will again throw login.php page for users.

Please let me know how can I reuse my login.php page successfully from html pages. Please also let me know any implementation specific suggestions (like creation of a seperate login page for html application which will act like a middleware taking the session variable from php and converting it into html (session) variable or something like that, so that my html applications can use it.

Thanks.

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,652
#2: May 11 '09

re: how to Share variables among php and html


what do you consider "HTML application"? HTML is just a bunch of static mark-up, which is rendered by the browser.

on the other hand side, PHP only works on the server (and is finished before anything reaches the browser), HTML only on the client, so you just need to print out in PHP to get it in HTML (but if this can be considered secure is more than questionable).
clain's Avatar
Member
 
Join Date: Feb 2007
Location: Chennai, INDIA
Posts: 68
#3: May 18 '09

re: how to Share variables among php and html


the options are..

renaming the html files to php and passing the session varilables through out the page.

other option is calling a hidden iframe which holds a php session control page [its really a dirty idea]

next option is a javascript that can communicate with php server page with ajax [this is too much complicated yet effective ]
prabirchoudhury's Avatar
Familiar Sight
 
Join Date: May 2009
Location: Wellington, New Zealand
Posts: 152
#4: May 18 '09

re: how to Share variables among php and html


read those basic posts, thereds and online tutorials


Pass data to another page?

Pass data to another page?

html form submit in php

php $_post, $_get and $_request
Reply

Tags
html, php


Similar PHP bytes