LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-14-2006, 08:00 PM   #1
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Rep: Reputation: 30
PHP Smarty session handling


Hi all!

I want to write a admin UI in Smarty but there are some problems. I don't know how to create a site that requires a username, passwd, compares to the data stored in mysql and if it's ok creates a logedin session.
I tried like that:

PHP Code:
include('admin.lib.php');

$admin = new Smarty_admin();
$conn = &NewADOConnection('mysql');
$conn->PConnect('localhost','root','','gasztrostudio');
if(!isset(
$_SESSION['logedin'])){
    
$r $conn->Execute("SELECT * FROM adminok WHERE uname = '".$_POST['uname']."' AND passwd = '".$_POST['passwd']."'");
    
$res=$r->GetArray();
    if(empty(
$res)){
        
$admin->display('login.tpl');
    }else{
        
$admin->display('admin_index.tpl');
        
$_SESSION['logedin']=true;
    }

After reloading the page the login window pops up. I use Apache 2 with PHP5

Dani
 
Old 12-14-2006, 09:08 PM   #2
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
Hi,
I think you are missing the initialization of the session. If my memory doesnt fail me at this time of the day, you need to call session_start(); every time a page is loaded so as to load the session if exists (or create it if it doesnt). In this way, you dont lose the 'logedin' value as you are losing it now.

But the idea of using the 'logedin' key to check if the user has gone through the login process is cool.

If that is not what is missing I can look up for some code I wrote... but tomorrow since it will take time and a clear mind, which I am lacking right now hehehehe

Cheers!
 
Old 12-15-2006, 10:37 AM   #3
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Original Poster
Rep: Reputation: 30
Got ya... You know I thought I have it in the code and when I reread it it was missing. LoL so yeah.... that was the problem.

Cheers
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Globals in PHP and Smarty ($_GET) vargadanis Programming 6 12-01-2006 07:21 PM
Php String Handling joelhop Programming 1 09-11-2006 11:21 PM
LXer: Smarty templating and presentation library for PHP LXer Syndicated Linux News 0 12-09-2005 05:53 PM
LXer: Smarty templating and presentation library for PHP LXer Syndicated Linux News 0 12-09-2005 02:36 PM
VNC Session Handling azzurro Linux - Networking 16 09-21-2004 04:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration