Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function Register($CONN, $iFirstName, $iLastName, $iUsername, $iEmailAddress, $iPassword, $iCountry, $iCity)
- {
- $SubmitOK = '1';
- $Core = new Core();
- $iPassword = password_hash($iPassword, PASSWORD_DEFAULT);
- $Core->CheckForEmpty(array('iFirstName', 'iLastName', 'iUsername', 'iEmailAddress', 'iPassword', 'iCountry'), 'index.php');
- if($SubmitOK == '1') {
- try {
- $SQL = 'INSERT INTO Users (FirstName, LastName, Username, Password, EmailAddress, City, Country) VALUES (:iFirstName, :iLastName, :iUsername, :iPassword, :iEmailAddress, :iCity, :iCountry)';
- $SQL = $CONN->prepare($SQL);
- $SQL->execute(array("iFirstName" => $iFirstName, "iLastName" => $iLastName, "iUsername" => $iUsername, "iPassword" => $iPassword, "iEmailAddress" => $iEmailAddress, "iCity" => $iCity, "iCountry" => $iCountry));
- $_SESSION['Success'] = 'Uspesno ste se registrovali';
- header('location: index.php');
- exit();
- } catch(PDOException $e) {
- echo "Error: " . $e->getMessage();
- }
- } else {
- $_SESSION['Error'] = 'Doslo je do greske! Molimo vas pokusajte ponovo';
- header('location: index.php');
- exit();
- }
- }
- <?php
- session_start();
- include 'includes.php';
- if($_SERVER['REQUEST_METHOD'] === 'POST') {
- $iFirstName = htmlspecialchars($_POST['iFirstName']);
- $iLastName = htmlspecialchars($_POST['iLastName']);
- $iPassword = $_POST['iPassword'];
- $iEmailAddress = htmlspecialchars($_POST['iEmailAddress']);
- $iUsername = htmlspecialchars($_POST['iUsername']);
- $iCountry = $_POST['iCountry'];
- $iCity = htmlspecialchars($_POST['iCity']);
- $User->Register($CONN, $iFirstName, $iLastName, $iUsername, $iEmailAddress, $iPassword, $iCountry, $iCity);
- }
- $Smarty->assign('Title', 'Home');
- $Smarty->assign('Message', $Core->GetMessage());
- $Smarty->display('header.tpl');
- $News = $Core->GetNews();
- $Important = $Core->GetImportant();
- $Smarty->assign('News', $News);
- $Smarty->assign('Important', $Important);
- $Smarty->display('index.tpl');
- $Smarty->display('footer.tpl');
- ?>
Add Comment
Please, Sign In to add comment