Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. header('Content-Type: text/html; charset=utf-8');
  4. $user = $_POST['score'];
  5. $score = $_POST['user'];
  6. $servername = "localhost";
  7. $username = "id463989_gazin";
  8. $password = "nabil2017";
  9. $dbname = "id463989_gazin2017";
  10.  
  11. $mysqli = new mysqli($servername, $username, $password, $dbname);
  12. $mysqli->set_charset("utf8");
  13.  
  14. mysqli_select_db( $mysqli, $dbname) or die ("could not load the database" . mysql_error());
  15.  
  16. $sql = "SELECT * FROM ranking WHERE user = '$user' ";
  17. $query = mysqli_query($mysqli, $sql);
  18. $numrows = mysqli_num_rows($query);
  19.  
  20. if ($numrows == 0){
  21. die ("Usuario nao existe");
  22. }else{
  23. while($row = mysqli_fetch_assoc($query)){
  24. if($score > $row['score']){
  25. $SetCoins = mysqli_query($mysqli, "UPDATE ranking SET score='$score' WHERE user='$user'") or die(mysql_error());
  26. }
  27. }
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement