note 104406 added to function.session-start

From: Date: Mon, 13 Jun 2011 21:18:49 +0000
Subject: note 104406 added to function.session-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-180500@lists.php.net to get a copy of this message
Hi guys, i have a problem.. i'm creating a web page about school's info.. i want to show school's name in the left side , i think it's ok doing with $_SESSION but part of the php code i didn't do it by myself i did generate with a software, that software generates a lot of functions i'm trying to understandig it now.. the school's name i'll get it using a unique id, which is one the user type in the login form like a username, then, i have a php file with one function that validate the password and in that same file i have another one for stablishment the session.. the function that i made is working but just if i put a static value in the id. function set_session() { $sql = " SELECT IdCentro, NombreCentro FROM usuarios "; $sql .= " WHERE IdCentro = '16248'"; #here i need something else $query = mysql_query($sql); $result = mysql_fetch_assoc($query); $_SESSION['is_successful_login'] = $result['NombreCentro']; } What way i can put on: "where IdCentro = " be the logged username?? look the other function: function art_check_userpw($username, $password) { $username = art_escape_sqlval($username); $password = art_escape_sqlval($password); $sql = " select Nivel, IdCentro, NombreCentro from usuarios "; $sql .= " where IdCentro = '" . strtolower(trim($username)) . "'"; $query = mysql_query($sql); if(!$query || (mysql_num_rows($query) < 1)) { return -1000; } $row = mysql_fetch_array($query); $dbpassword = stripslashes(art_rowdata($row, 1)); $dbuserlevel = stripslashes(art_rowdata($row, 0)); $password = stripslashes($password); if ($password == $dbpassword) { art_set_userinfo($username, $dbuserlevel); return $dbuserlevel; } else { return -1000; } } There another way for including: $username variable from this function to set_session function?? there one way easist to do what i need?? Thanks!! pd. sorry for my poor english, i'm hispanic and know just a little the english. ---- Server IP: 69.147.83.197 Probable Submitter: 200.62.110.68 ---- Manual Page -- http://www.php.net/manual/en/function.session-start.php Edit -- https://master.php.net/note/edit/104406 Del: integrated -- https://master.php.net/note/delete/104406/integrated Del: useless -- https://master.php.net/note/delete/104406/useless Del: bad code -- https://master.php.net/note/delete/104406/bad+code Del: spam -- https://master.php.net/note/delete/104406/spam Del: non-english -- https://master.php.net/note/delete/104406/non-english Del: in docs -- https://master.php.net/note/delete/104406/in+docs Del: other reasons-- https://master.php.net/note/delete/104406 Reject -- https://master.php.net/note/reject/104406 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180500) next »