Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. function login($user, $password){
  2. global $server, $owner, $psw, $DB;
  3. if(!($link = mysqli_connect( $server, $owner, $psw, $DB))){
  4. echo "invalid connection";
  5. }
  6. $user=mysqli_real_escape_string($link, $user);
  7. $password=mysqli_real_escape_string($link, $password);
  8. $password=md5($password);
  9. $query="select email from utenti where password='".$password."' and email='".$user."';";
  10. if(!($res=mysqli_query($link, $query))){
  11. //echo "invalid query";
  12. syslog(LOG_ERR,"invalid query");
  13. }
  14. if(mysqli_num_rows($res)==0){
  15. //echo "login failed";
  16. syslog(LOG_INFO,"login failed");
  17. mysqli_free_result($res);
  18. mysqli_close($link);
  19. return false;
  20. }
  21. $_SESSION['231587_logged']=true;
  22. $_SESSION['231587_lastvisit']=time();
  23. mysqli_free_result($res);
  24. mysqli_close($link);
  25. return true;
  26. }
  27.  
  28. $.ajax({
  29. url: url,
  30. data: "&macchina="+machine+"&inizio="+start,
  31. method: "POST",
  32. cache: false,
  33. success: function (response){
  34. //document.getElementById("risposta").innerHTML =response;
  35. //window.location.href = window.location.href; //aggiorna la pagina senza rimandare i dati
  36. //document.write(response);
  37. console.log(response);
  38. },
  39. error: function (xhr, ajaxOptions, thrownError) {
  40. alert(xhr.status);
  41. alert(thrownError);
  42. }
  43. });
  44.  
  45. if(isset($_POST['macchina'], $_POST['inizio']) && $_SESSION['231587_logged']){
  46. //echo "parametri settati";
  47. if(!stringEmpty()){
  48. deleteReservation(validateInput($_POST['macchina']), validateInput($_POST['inizio']));
  49. echo "tornato dalla funzione";
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement