Advertisement
wmdcms

Untitled

Oct 3rd, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2. include 'config.php';
  3. //Konekcija na bazu
  4. $con = mysql_connect($hostname,$db_username,$db_password);
  5. if (!$con)
  6. {
  7. die('Neuspjela konekcija: ' . mysql_error());
  8. }
  9. mysql_select_db($db_name, $con);
  10.  
  11. //Prijava korisnika
  12. $username= $_POST["userid"];
  13. $password= $_POST["password"];
  14. if (empty($username) || empty($password)){
  15. die(header("location: index.php?pristup=greska"));
  16. }
  17.  
  18. $sql = mysql_query("select password from korisnici where username ='".$username."'");
  19. $result = mysql_fetch_array($sql);
  20. if(!$result)
  21. die(header("location: index.php?pristup=greska"));
  22. if ($password != $result['password']){
  23. die(header("location: index.php?pristup=greska"));
  24. }
  25. $sql_admin = mysql_query("select PacijentID from korisnici where username ='".$username."'");
  26. $result_admin = mysql_fetch_array($sql_admin);
  27. session_start();
  28. $_SESSION['korisnik'] = $username;
  29. if ($result_admin['PacijentID'] == '0'){
  30. header("location: administrator/index.php");
  31. }else{
  32. header("location: main.php?korisnik=$username");
  33. }
  34. mysql_close($con);
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement