1 |
<?php |
<?php |
2 |
$error = ""; |
$error = ""; |
3 |
if ($posalji) { |
if ($posalji) { |
4 |
include("inc/conn.php"); |
if (!$username) $error = "Morate upisati korisničko ime."; |
5 |
$sql = "SELECT email FROM users WHERE (username = '$username')"; |
if (!$error) { |
6 |
$sth = $dbh->prepare($sql); |
include("inc/conn.php"); |
7 |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
$sql = "SELECT email FROM users WHERE (username = '$username')"; |
8 |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
$sth = $dbh->prepare($sql); |
9 |
$email = $sth->fetchrow_array(); |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
10 |
$sth->finish(); |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
11 |
if ($email) $email = array_shift($email); |
$email = $sth->fetchrow_array(); |
12 |
if (!$email) $error = "Nepoznato korisničko ime."; |
$sth->finish(); |
13 |
|
if ($email) $email = array_shift($email); |
14 |
|
if (!$email) $error = "Nepoznato korisničko ime."; |
15 |
|
} |
16 |
if (!$error) { |
if (!$error) { |
17 |
$pass = GeneratePassword(); |
$pass = GeneratePassword(); |
18 |
$sql = "UPDATE users SET password = '".md5($pass)."' WHERE (username = '$username')"; |
$sql = "UPDATE users SET password = '".md5($pass)."' WHERE (username = '$username')"; |
22 |
} |
} |
23 |
$tpl->assign("username", $username); |
$tpl->assign("username", $username); |
24 |
$tpl->assign("error", $error); |
$tpl->assign("error", $error); |
25 |
$tpl->assign("done", $error ? false : true); |
$tpl->assign("done", !$posalji || $error ? false : true); |
26 |
?> |
?> |