Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> odświeżanie
john_doe
post
Post #1





Grupa: Zarejestrowani
Postów: 873
Pomógł: 25
Dołączył: 24.07.2005

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


Witam, po lekturze w dziale Przypięte, zgodnie z fajnym rozwiązaniem nospora

mam coś takiego, jednak nie działa to należycie

  1. <?php
  2. $_SESSION['token'] = ""; // TUUUUUUUTAJ
  3. print 'Podaj nazwę nowej kategorii: ';
  4. include( '../FKNadmin.php' );
  5. include( '../db/querries.php' );
  6. include( '../db/connect.php' );
  7.  
  8.  
  9. showNewCategoryForm();
  10.  
  11. $refreshHandler =  refreshHandler( $_SESSION['token'], $_POST['token'] );
  12.  
  13. print $refreshHandler;
  14.  
  15. if ( $_POST['addCatSubmit'])
  16. {    
  17.    if( $refreshHandler == 1 )
  18.    {
  19.        connect( $INSERT_CATEGORY );
  20.    }
  21. }    
  22.  
  23. $result = connect( $SELECT_CATEGORIES );
  24.  
  25. if ( countResults( $result ) > 0 )
  26. {
  27.    
  28.    print '<table border="1">
  29.                <tr>
  30.                    <th>Id</th>
  31.                    <th>Nazwa kategorii</th>
  32.                    <th>Akcje<th>
  33.                </tr>';
  34.    
  35.        while ( $row = mysql_fetch_array( $result ) )
  36.        {
  37.            print '<tr>';
  38.                
  39.            print '<td>' . $row[0] . '</td><td>' . $row[1] . '</td>';
  40.            
  41.            print '<td>
  42.                            
  43.                <a href="java script:showDeleteFormat('deleteCategoryConfirm.php?id=' . $row[0] . '')">
  44.                    <img src="../img/b_drop.png" title="Usuń kategorię" />
  45.                </a>                            
  46.            </td>';
  47.                
  48.            print '</tr>';
  49.        }
  50. } else print 'Brak kategorii';
  51. ?>


i plik z funkcjami

  1. <?php
  2. function showNewCategoryForm()
  3. {
  4.    $token = rand(0, 1000000);
  5.    
  6.    print '<form action="index.php" method="POST" >';
  7.  
  8.        print '<input type="text" name="newCategory" />';
  9.            
  10.        print '<input type="hidden" name="token" value="' . $token . '" />';
  11.            
  12.        print '<input type="submit" value="Dodaj" name="addCatSubmit" />';
  13.    
  14.    print '</form>';
  15. }
  16.  
  17. function refreshHandler( $sesja, $post )
  18. {
  19.    if( isset( $sesja ) && $sesja <> $post )
  20.    {
  21.        $value = 1;
  22.        //$sesja = $post;
  23.        $_SESSION['token'] = $_POST['token'];
  24.    }else $value = 0;
  25.    
  26.    return $value;
  27.    
  28. }
  29. ?>


całość działa ok, gdy za 1szym razem odkomentuję linie $_session['token'] = ""; pozwole odświeżyć
potem ja komentuje i wtedy wszystko działa jak należy hehe. pokrętne cudo.
czuję, że brakuje mi tu czegoś z tą zmienną sesyjna token....
pomocy

pozdrawiam
Go to the top of the page
+Quote Post

Posty w temacie
- john_doe   odświeżanie   26.07.2009, 14:43:21
- - tmka   edit: hmmm, po dłuższym zastanowieniu st...   26.07.2009, 15:16:53


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

 



RSS Aktualny czas: 21.08.2025 - 10:17