Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Nie działa przekierowanie - skrypt się wykonuje
Forum PHP.pl > Forum > PHP
DobryCover
Mam problem z przekierowaniem.
Cały skrypt się wykonuje ale po wykonaniu nie przekierowuje do danego pliku (rps.php).

Skrypt:
  1. <?php
  2. require_once ('header.php');
  3. global $pdo;
  4. if(isset($_POST["battleCreate"])) {
  5. global $pdo;
  6. $key = "66DF348E89D52A9A1A6AB6308C94E0E3";
  7. $auth = new SteamAuth();
  8. $auth->SetOnLoginCallback(function($steamid){
  9. return true;
  10. });
  11. $auth->SetOnLoginFailedCallback(function(){
  12. return true;
  13. });
  14. $auth->Init();
  15. $SteamCache = "steamauthRPS.json.cache";
  16. $link = null;
  17. define("MAX_CACHE_LIFETIME", 60 * 60 * 6);
  18. if(file_exists($SteamCache)) {
  19. if (time() - filemtime($SteamCache) < MAX_CACHE_LIFETIME) {
  20. $link = file_get_contents($SteamCache);
  21. }
  22. }
  23. if(empty($link)) {
  24. $link = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='.$key.'&steamids='.$auth->SteamID.'&format=json');
  25. file_put_contents($SteamCache, $link);
  26. }
  27. $profile = json_decode($link, true);
  28. if(isset($profile)) {
  29. $steamid = $auth->SteamID;}
  30. $stmt = $pdo->prepare("SELECT personaname, coins FROM users WHERE steamid = $steamid");
  31. $stmt -> execute();
  32. while($row = $stmt -> fetch(PDO::FETCH_ASSOC)){
  33. $personaname = $row['personaname'];
  34. $coinsUser = $row['coins'];}
  35. $coins = $_POST['coinsAmount'];
  36. $symbol = $_POST['Symbol'];
  37. $defcount = $pdo->query("SELECT COUNT(*) FROM rpsbattles WHERE defender = '$personaname' and finished = 'NO'")->fetchColumn();
  38. if($defcount >= 5) {
  39. header('Location: rps.php?error=1');
  40. } else {
  41. if($coins > $coinsUser) {
  42. header('Location: rps.php?error=2');
  43. } else {
  44. $stmt = $pdo->prepare("INSERT INTO rpsbattles (id, defender, defender_steamid, defender_symbol, attacker, attacker_steamid, attacker_symbol, coins, finished) VALUES (null, '$personaname', '$steamid', '$symbol', '', '', '', '$coins', 'NO')");
  45. $stmt -> execute();
  46. $calcResult = $coinsUser - $coins;
  47. $stmt = $pdo->prepare("UPDATE users SET coins = '$calcResult' WHERE steamid = $steamid");
  48. $stmt -> execute(array(1));
  49. header('Location: rps.php');
  50. }
  51. }
  52. }
  53. ?>

salfunglandyare
Jaki komunikat dostajesz? Jeśli coś w rodzaju 'Headers already sent' daj tuż po <?php


a tuż przed ?>
DobryCover
Problem był właśnie w tym, że nie otrzymywałem komunikatu.
Ale twoja metoda pomogła, dzięki smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.