1 |
ravilov |
1.1 |
<?php |
2 |
|
|
$error = ""; |
3 |
|
|
if ($posalji) { |
4 |
|
|
include("inc/conn.php"); |
5 |
|
|
$sql = "SELECT email FROM users WHERE (username = '$username')"; |
6 |
|
|
$sth = $dbh->prepare($sql); |
7 |
|
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
8 |
|
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
9 |
|
|
$email = $sth->fetchrow_array(); |
10 |
|
|
$sth->finish(); |
11 |
|
|
if ($email) $email = array_shift($email); |
12 |
|
|
if (!$email) $error = "Nepoznato korisnièko ime."; |
13 |
|
|
if (!$error) { |
14 |
|
|
$pass = GeneratePassword(); |
15 |
|
|
$sql = "UPDATE users SET password = '".md5($pass)."' WHERE (username = '$username')"; |
16 |
|
|
$dbh->dbh_do($sql); |
17 |
|
|
$error = mail($email, "PLIVAmed.net - Registracija", "\nNova lozinka: $pass\n", "From: registracija@plivamed.net") ? "" : "Gre¹ka prilikom slanja e-mail poruke."; |
18 |
|
|
} |
19 |
|
|
} |
20 |
|
|
$tpl->assign("username", $username); |
21 |
|
|
$tpl->assign("error", $error); |
22 |
|
|
$tpl->assign("done", $error ? false : true); |
23 |
|
|
?> |