here's my whole code:
<?php
$dbhost="localhost";
$dbuser="user";
$dbname="name";
$db = mysql_connect("$dbhost", "$dbuser");
mysql_select_db("$dbname");
$login=$_POST['login'];
$passwd=$_POST['passwd'];
if (!$login) {
echo "Something's wrong with the user name field";
} elseif (!$passwd) {
echo "Something's wrong with the user name";
} elseif {
check_logina($login, $passwd)) {
print_mb();
) else {
echo "mistake";
}
mysql_close($db);
?>
<?php
function check_logina($login, $passwd)
{
$failas = "/var/where/file/passwd";
$duomenys = fopen ($failas, "r");
$index=0;
while (!feof($duomenys)) {
$eilute[$index] = fgetss($duomenys, 100);
list($useris, $slaptazodis, $workdyra, $kazkas) = explode("*", $eilute[$index]);
if ($login==$useris && $passwd==$slaptazodis) {
return 1;
}
$index++;
}
fclose ($duomenys);
} else {
return 0;
}
?>
<?php
function print_mb() {
global $dbhost, $dbname, $dbuser, $login, $kazkas;
$rezult = mysql_query("SELECT round(sum(issiusta)/1024/1024) from statistika where vardas='".$login."' and HOUR(laikas) > 9 and HOUR(laikas) < 21");
while ($row = mysql_fetch_row($rezult))
echo $row[0].'<br />';
mysql_free_result($rezult);
}
?>
the main idea is to print uout the number of Mbytes a user has used up during DAY (9-21) hours.
the login and passwd come from another php file, from a form.
the function function print_mb works fine alone, but i think sonething's wrong with the function check_logina or at the begining of my code:
if (!$login) {
echo "Something's wrong with the user name field";
} elseif (!$passwd) {
echo "Something's wrong with the user name";
} elseif {
check_logina($login, $passwd)) {
print_mb();
) else {
echo "mistake";
}
mysql_close($db);
please help... i've been working on THIS code for about a week now, and just can't figure it out myself 🙁