Guest User

Untitled

a guest
Oct 23rd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. public function Register($CONN, $iFirstName, $iLastName, $iUsername, $iEmailAddress, $iPassword, $iCountry, $iCity)
  2. {
  3.  
  4. $SubmitOK = '1';
  5. $Core = new Core();
  6. $iPassword = password_hash($iPassword, PASSWORD_DEFAULT);
  7. $Core->CheckForEmpty(array('iFirstName', 'iLastName', 'iUsername', 'iEmailAddress', 'iPassword', 'iCountry'), 'index.php');
  8.  
  9.  
  10. if($SubmitOK == '1') {
  11. try {
  12. $SQL = 'INSERT INTO Users (FirstName, LastName, Username, Password, EmailAddress, City, Country) VALUES (:iFirstName, :iLastName, :iUsername, :iPassword, :iEmailAddress, :iCity, :iCountry)';
  13. $SQL = $CONN->prepare($SQL);
  14. $SQL->execute(array("iFirstName" => $iFirstName, "iLastName" => $iLastName, "iUsername" => $iUsername, "iPassword" => $iPassword, "iEmailAddress" => $iEmailAddress, "iCity" => $iCity, "iCountry" => $iCountry));
  15. $_SESSION['Success'] = 'Uspesno ste se registrovali';
  16. header('location: index.php');
  17. exit();
  18. } catch(PDOException $e) {
  19. echo "Error: " . $e->getMessage();
  20. }
  21. } else {
  22. $_SESSION['Error'] = 'Doslo je do greske! Molimo vas pokusajte ponovo';
  23. header('location: index.php');
  24. exit();
  25. }
  26. }
  27.  
  28. <?php
  29. session_start();
  30. include 'includes.php';
  31.  
  32.  
  33.  
  34. if($_SERVER['REQUEST_METHOD'] === 'POST') {
  35. $iFirstName = htmlspecialchars($_POST['iFirstName']);
  36. $iLastName = htmlspecialchars($_POST['iLastName']);
  37. $iPassword = $_POST['iPassword'];
  38. $iEmailAddress = htmlspecialchars($_POST['iEmailAddress']);
  39. $iUsername = htmlspecialchars($_POST['iUsername']);
  40. $iCountry = $_POST['iCountry'];
  41. $iCity = htmlspecialchars($_POST['iCity']);
  42.  
  43.  
  44. $User->Register($CONN, $iFirstName, $iLastName, $iUsername, $iEmailAddress, $iPassword, $iCountry, $iCity);
  45. }
  46. $Smarty->assign('Title', 'Home');
  47. $Smarty->assign('Message', $Core->GetMessage());
  48. $Smarty->display('header.tpl');
  49.  
  50. $News = $Core->GetNews();
  51. $Important = $Core->GetImportant();
  52. $Smarty->assign('News', $News);
  53. $Smarty->assign('Important', $Important);
  54. $Smarty->display('index.tpl');
  55. $Smarty->display('footer.tpl');
  56.  
  57. ?>
Add Comment
Please, Sign In to add comment