$name = $_POST['inputName']; $pass = $_POST['inputPassword']; $dataURI = $_POST['inputImg']; $encodedData = explode(',', $dataURI)[1]; $data = $func->runProc("insert_user", array($name, $email, $pass, $encodedData), false); if ($data[0] != "00000") { $error = 'Somebody registered with this email!'; } } else { if (isset($_POST['forgottClick'])) { $email = $_POST['ForgottEmail']; $data = $func->runFunc("get_users", array($email, $email, '%', 0), 1, false); if (sizeof($data) == 0) { $error = 'User not registered with whit these email!'; } else { if (!send_mail($data[0], 'Forgotten password', $_SERVER["HTTP_HOST"], current_HTTP(), 'reg_forgot.php')) { $error = 'Something wrong with email sending!'; } } } } } function send_mail($param, $subject, $from, $path, $file) { $to = $param['email']; $subject = $subject; $message = file_get_contents($file); $message = str_replace('#name#', $param['name'], $message); $message = str_replace('#mail#', $param['email'], $message); $message = str_replace('#pass#', $param['pass'], $message); $message = str_replace('#path#', $path, $message);
<?php @session_start(); if (isset($_REQUEST['logout'])) { destSession(); } if (!isset($_SESSION['user'])) { header('location:' . current_HTTP() . 'login.php'); exit; } function destSession() { $id = session_id(); $_SESSION = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); } session_destroy(); @unlink(ini_get('session.save_path') . '/sess_' . $id); } function current_HTTP() { $arr = explode('/', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); unset($arr[sizeof($arr) - 1]); $index = implode('/', $arr) . '/'; return $index; } ?> <!DOCTYPE html> <html lang="en">