Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem ze skryptem formularz kontaktowy
shogunzmc
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 29.09.2010

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


witam umieściłem na stronce następujący kod

w pliku kontakt.html:

  1. <form method="post" action="wyslij.php" name="kontakt">
  2. <div><li>
  3. <label for="nick">Imię: </label>
  4. <ul><input type="text" class="text" id="nick" name="nick" ></div>
  5. <div><li>
  6. <label for="temat">Temat: </label><ul><input type="text" name="temat" class="text" id="temat" ></div>
  7. <div><li><label for="mail">Twój adres e-mail: </label><ul><input type="text" name="mail" class="text" id="mail" ></div>
  8. <div><li>
  9. <label for="tresc">Treść: </label>
  10. <ul>
  11. <textarea name="tresc" id="tresc" rows="5" cols="50" ></textarea>
  12. </div>
  13. <div>
  14. <ul>
  15. <input type="submit" value="Wyslij" /></div>
  16. </form>


natomiast plik wyslij.php wygląda następująco

  1. <?php
  2.  
  3. if (!nick || !mail || !temat || !tresc)
  4. {
  5. echo "Nie uzupelniles wszystkich rubryk.";
  6. }
  7. $charset = 'Windows-1250';
  8. $wiadomosc =
  9. "Imie: ".$_POST['nick']."
  10.  
  11. e- mail: ".$_POST['mail']."
  12.  
  13. Tresc: ".$_POST['tresc']." ";
  14.  
  15. $tematyka = "Formularz kontaktowy".$temat;
  16.  
  17.  
  18. mail ("mojadresemail", $tematyka, $wiadomosc );
  19. echo "<script type=\"text/javascript\">window.alert('Wiadomość zostala wyslana');</script>";
  20. ?>


i wszystko działa email dochodzi jak należy z tym że wyświetla się informacja email został wysłany i biała strona a chciałbym aby powracało na strone z formularzem automatycznie ale nie za bardzo wiem jak to mam teraz zrobić


PS. z góry dziękuję za pomoc

Ten post edytował shogunzmc 29.09.2010, 11:19:42
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Uzyj header i przekieruj po np. 5 sekundach spowrotem na swoj formularz
http://pl.php.net/manual/pl/function.header.php
Cytat
Several times this one is asked on the net but an answer could not be found in the docs on php.net ...

If you want to redirect an user and tell him he will be redirected, e. g. "You will be redirected in about 5 secs. If not, click here." you cannot use header( 'Location: ...' ) as you can't sent any output before the headers are sent.

So, either you have to use the HTML meta refresh thingy or you use the following:

<?php
header( "refresh:5;url=wherever.php" );
echo 'You\'ll be redirected in about 5 secs. If not, click <a href="wherever.php">here</a>.';
?>

Hth someone
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: 14.09.2025 - 15:43