Guest User

Untitled

a guest
Aug 21st, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. $PID = $_POST['PID'];
  9. $RID = $_POST['RID'];
  10. $UID = $_POST['UID'];
  11.  
  12. $MEDIA = $_POST['MEDIA'];
  13. $lTIME = $_POST['TIME'];
  14. $STATUS = $_POST['STATUS'];
  15. $SCORE = $_POST['SCORE'];
  16. $DETAILS = $_POST['DETAILS'];
  17.  
  18.  
  19.  
  20.  
  21. $user = 'admin';
  22. $password = "elder";
  23. $host = '127.0.0.1';
  24. $db = 'mediamed';
  25.  
  26. $link = mysql_connect($host, $user, $password);
  27. if (!$link) {
  28. die('Could not connect: ' . mysql_error());
  29. }
  30.  
  31. mysql_select_db($db,$link);
  32.  
  33. $sql = "SELECT * FROM tracking WHERE PID = '$PID' AND RID = '$RID' AND UID = '$UID'";
  34.  
  35.  
  36. $result = mysql_query($sql, $link);
  37.  
  38.  
  39.  
  40. //Se non ci sono risultati, inserisco una riga nel tracking
  41. $num_rows = mysql_num_rows($result);
  42.  
  43.  
  44. if($num_rows==0){
  45.  
  46. $sql_insert = "INSERT INTO `tracking` (
  47.  
  48. `PID` ,
  49. `RID` ,
  50. `UID` ,
  51. `MEDIA` ,
  52.  
  53. `time` ,
  54. `status` ,
  55. `score` ,
  56. `details`
  57. )
  58. VALUES (
  59. '$PID' , '$RID' , '$UID' , '$MEDIA' , '$lTIME' , 'N' , '$SCORE' , '$DETAILS'
  60. );
  61. ";
  62.  
  63. mysql_query($sql_insert, $link);
  64.  
  65.  
  66. }else {
  67. //ALTRIMENTI faccio l'update di quello che gia c'era
  68.  
  69. if($row['status']!='C'){
  70. $row = mysql_fetch_assoc($result);
  71. $secs = (int)$row['time']+(int)$lTIME;
  72.  
  73. $sql_update = "
  74. UPDATE `tracking` SET `time` = '$secs',
  75. `status` = '$STATUS',
  76. `score` = '$SCORE',
  77. `details` = '$DETAILS' WHERE
  78. PID = '$PID' AND RID = '$RID' AND UID = '$UID' LIMIT 1 ;
  79. ";
  80.  
  81. mysql_query($sql_update, $link);
  82. }
  83. }
  84. echo 'error=0';
  85. ?>
Add Comment
Please, Sign In to add comment