Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Problem z Refresh, Proszę o pomoc
Snap
post
Post #1





Grupa: Zarejestrowani
Postów: 75
Pomógł: 4
Dołączył: 29.05.2005

Ostrzeżenie: (0%)
-----


Witam (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Mam mały problem z pewnym skryptem, oto on (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Przedstawiam Państwu mój skrypt wylogowania (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Problem w tym że nie che mi odświeżyć strony za pierwszym kliknięciem (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

  1. <?php
  2. ....
  3. if(isset($_SESSION['admin']))
  4. {
  5.  echo '<b>Witaj: '.$admin.' </b><br>';
  6.  
  7.  echo '<form method="post" action="index.php?a=logout"><input type="submit" value="Logout" name="submit" class="submit" /></form>';
  8.  
  9. if($_GET['a'] == logout) 
  10. {
  11. echo '<META HTTP-EQUIV="Refresh" CONTENT="1; URL=index.php">';
  12. }
  13. } else {
  14. ....
  15. ?>

Proszę o pomoc (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował Snap 2.03.2007, 11:18:45
Go to the top of the page
+Quote Post
x3m
post
Post #2





Grupa: Zarejestrowani
Postów: 18
Pomógł: 1
Dołączył: 23.01.2007
Skąd: Ostróda

Ostrzeżenie: (0%)
-----


A dlaczego Refresh wywołujesz na środku strony? (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował x3m 2.03.2007, 12:09:11
Go to the top of the page
+Quote Post
misiek172
post
Post #3





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


użyj:

  1. <script language='JavaScript'>
  2. window.location='';


najlepiej wcześniej zdefiniuj sobie funkcje w php:

  1. <?php
  2. function reload($co){
  3. <script language='JavaScript'>
  4. window.location='".$co."';
  5. </script>
  6. ";
  7. }
  8. ?>


Ten post edytował misiek172 2.03.2007, 12:36:54
Go to the top of the page
+Quote Post
Snap
post
Post #4





Grupa: Zarejestrowani
Postów: 75
Pomógł: 4
Dołączył: 29.05.2005

Ostrzeżenie: (0%)
-----


Nadal to samo (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Musze 2 raz kliknąć żeby przycisk mi się zmienił na formularz logowania (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował Snap 2.03.2007, 13:09:06
Go to the top of the page
+Quote Post
misiek172
post
Post #5





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


tak (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
lub inna nazwe pliku (IMG:http://forum.php.pl/style_emoticons/default/haha.gif)
Go to the top of the page
+Quote Post
Snap
post
Post #6





Grupa: Zarejestrowani
Postów: 75
Pomógł: 4
Dołączył: 29.05.2005

Ostrzeżenie: (0%)
-----


Nie działa (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) ani ten skrypt ani w przycisku
  1. <?php
  2. onclick="window.location.href='.$index.'"
  3. ?>
Pomocy (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Nadal trzeba 2x w przycisk kliknąć
Go to the top of the page
+Quote Post
misiek172
post
Post #7





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


hmm no to błąd jest w innym miejscu... (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
heaven
post
Post #8





Grupa: Nieautoryzowani
Postów: 92
Pomógł: 15
Dołączył: 21.10.2006

Ostrzeżenie: (0%)
-----


a nie lepiej uzyc funkcji header?
  1. <?php
  2. header('Location: index.php')
  3. ?>

tylko wtedy na samym poczatku skryptu musisz dodac ob_start(); jesli nie masz
Go to the top of the page
+Quote Post
Snap
post
Post #9





Grupa: Zarejestrowani
Postów: 75
Pomógł: 4
Dołączył: 29.05.2005

Ostrzeżenie: (0%)
-----


Chodzi Ci o Skrypt
  1. <?php
  2. if(isset($_SESSION['admin']))
  3. {
  4.  echo '<b>Witaj: '.$admin.' </b><br>';
  5.  
  6.  echo '<form method="post" action="index.php?a=logout"><input type="submit" value="Logout" name="submit" class="submit" /></form>';
  7.  
  8. if($_GET['a'] == logout) 
  9. {
  10. }
  11. } else {
  12. ?>

czy o cały plik ?

Cytat(misiek172 @ 2.03.2007, 13:26:30 ) *
hmm no to błąd jest w innym miejscu... (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Tylko że mi nigdzie błędu nie wywala :/ Poprostu muszę 2x kliknąć w przycisk i żadne refresh, location nic nie zmienia, trzeba 2x kliknać

Ten post edytował Snap 2.03.2007, 13:37:07
Go to the top of the page
+Quote Post
misiek172
post
Post #10





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


Cytat(Snap @ 2.03.2007, 13:38:15 ) *
Tylko że mi nigdzie błędu nie wywala :/ Poprostu muszę 2x kliknąć w przycisk i żadne refresh, location nic nie zmienia, trzeba 2x kliknać


Nie chodzi mi o błąd w składni PHP tylko w strukturze dokumentu. A takie błędy nigdy nie są wywalane ;P
Go to the top of the page
+Quote Post
heaven
post
Post #11





Grupa: Nieautoryzowani
Postów: 92
Pomógł: 15
Dołączył: 21.10.2006

Ostrzeżenie: (0%)
-----


  1. <?php
  2. if(isset($_SESSION['admin']))
  3. {
  4.  echo '<b>Witaj: '.$admin.' </b><br>';
  5.  
  6.  echo '<form method="post" action="index.php?a=logout"><input type="submit" value="Logout" name="submit" class="submit" /></form>';
  7.  
  8. if($_GET['a'] == logout) 
  9. {
  10.  header('Location: index.php');
  11. }
  12. } else {
  13. ?>

i to nie dziala?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) tylko ob_start musi byc na samym poczatku pliku ktory wywolywany jest z przegladarki
Go to the top of the page
+Quote Post
Snap
post
Post #12





Grupa: Zarejestrowani
Postów: 75
Pomógł: 4
Dołączył: 29.05.2005

Ostrzeżenie: (0%)
-----


Tak to działa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) a Ob_Start nie musi mieć zakonczenia jakiegoś (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) hehe

Dałem
  1. <?php
  2. ?>
za
  1. <?php
  2. } else { }
  3. ?>
W skrypcie podanym wyżej

Ten post edytował Snap 2.03.2007, 15:48:44
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 05:08