note 104406 rejected from function.session-start by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Jun 2011 21:20:59 +0000 |
| Subject: | note 104406 rejected from function.session-start by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180502@lists.php.net to get a copy of this message | ||
Note Submitter: calex dot jose at gmail dot com
----
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.