i have index.html contains login form. when user submits proceeds login.php , when user verified, heads index.html. verified username stored in session variable called username. want username shown @ top of index.html. 'hi ' or 'hi guest' if session variable empty. please help.
update: think ajax or jquery can retrieve session variable. plum ' s idea should work isn't. request post full fledged files. thanks.
add php page check-session.php , put following code
<?php if(!session_id())session_start(); $sessval=isset($_session['guest']) ? $_session['guest'] : null; echo $sessval; ?>
and underneath index.html page put javascript code:
$(document).ready(function(){ $.get("check-session.php", function(data, status){ if(data) $("#guestcontainer").html('hi'+data); else $("#guestcontainer").html(null); });});
this jquery load function show guest's name.
Comments
Post a Comment