Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Formularz kontaktowy
Forum PHP.pl > Forum > PHP
kamilo90
Głowie się i głowie i nie wiem czemu mój formularz nie działa sad.gif nie moge znaleźć żadnego błędu :/
Proszę jakiegoś speca o looknięcie w kod (dla was to będzie minutka)

  1. <?php
  2. if (empty($_POST['submit'])) {
  3.  
  4.    echo '<table align="center" border="0" cellspacing="3" cellpadding="0"><form method="post">
  5. <tr>
  6. <td align="right" class="uni_01">subject </td>
  7. <td class="uni_01">
  8. <input type="text" name="imie" size="35" value="" class="kontakt"></td>
  9. </tr>
  10. <tr>
  11. <td align="right" class="uni_01">e-mail </td>
  12. <td class="uni_01">
  13. <input type="text" name="email" size="35" value="" class="kontakt">
  14. </td>
  15. </tr>
  16. <tr>
  17. <td align="right" class="uni_01">message </td>
  18. <td class="uni_01">
  19. <textarea name="tresc" cols="50" rows="14"></textarea>
  20. </td>
  21. </tr>
  22. <tr>
  23. <td align="right" valign="top" class="uni_01">&nbsp;</td>
  24.  
  25. <td class="uni_01">
  26. <input style="font-weight: bold;" type="submit" name="submit" value="submit">
  27. <input type="reset" value="reset"></form>
  28. </td>
  29. </tr>
  30. </table>';
  31. }
  32. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email'])) {
  33.    $message = 'Temat: $_POST[imie]\n\nTreśc wiadomości: $_POST[tresc]';
  34.    $header = 'From: $_POST[email] <$_POST[email]>';
  35.    @mail("kawex@scores24.net","KaweX.com - $_POST[imie]","$message","$header")
  36.    or die('Nie udalo sie wyslac wiadomości');
  37.  
  38.   echo '<center><font color="#C3A54D">Your email has been sent.<br><br>We will contact you as soon as possible.</font></center>
  39. <script type="text/javascript">setTimeout('window.location.href=http://kawex.com',7000)</script>';
  40. }
  41. else echo '<center><blink><font color="#C3A54D">!!</font></blink> Do not leave any fields blank <blink><font color="#C3A54D">!!</font></blink><br><br>[ <a href="contact">back</a> ] </center>';
  42.  
  43. ?>
Spawnm
<form method="post">
gdzie action='strona.php' ?

  1. <?php
  2. echo '<center><font color="#C3A54D">Your email has been sent.<br><br>We will contact you as soon as possible.</font></center>
  3. <script type="text/javascript">setTimeout('window.location.href=http://kawex.com',7000)</script>'
  4. ?>

window.location dałeś po za ' przez co jest traktowane jak zmienna,
kamilo90
nie kapuje... to jak ma wyglądać ta linijka bo nie rozumiem

  1. <?php
  2. <script type="text/javascript">setTimeout('window.location.href=http://kawex.com',7000)</script>'
  3. ?>
Spawnm
tak:
  1. <?php
  2. echo '<center><font color="#C3A54D">Your email has been sent.<br><br>We will contact you as soon as possible.</font></center>
  3. <script type="text/javascript">setTimeout('window.location.href=http://kawex.com',7000)</script>';
  4. ?>

lub tak:
  1. <?php
  2. echo '<center><font color="#C3A54D">Your email has been sent.<br><br>We will contact you as soon as possible.</font></center>
  3. <script type="text/javascript">setTimeout("window.location.href=http://kawex.com",7000)</script>';
  4. ?>
johnson
Nie mam pewności, że to pomoże, ale moim zdaniem powinieneś wyciągnąć znaczniki <form> poza tabelę, czyli:

  1. <form method="post">
  2. <table align="center" border="0" cellspacing="3" cellpadding="0">
  3.  
  4. ...
  5.  
  6. </form>


a jeśli chodzi o action to nie musi być, jeśli nie ma to dane są przesyłane do tego samego pliku.
TrevorGryffits
A to może dowiemy się co nie działa? Tylko, błagam, nie pisz, że kod:)
Spyder
  1. <?php
  2. if (empty($_POST['submit'])) {
  3.  
  4. ?>
  5. <table align="center" border="0" cellspacing="3" cellpadding="0"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
  6. <tr>
  7. <td align="right" class="uni_01">subject </td>
  8. <td class="uni_01">
  9. <input type="text" name="imie" size="35" value="" class="kontakt"></td>
  10. </tr>
  11. <tr>
  12. <td align="right" class="uni_01">e-mail </td>
  13. <td class="uni_01">
  14. <input type="text" name="email" size="35" value="" class="kontakt">
  15. </td>
  16. </tr>
  17. <tr>
  18. <td align="right" class="uni_01">message </td>
  19. <td class="uni_01">
  20. <textarea name="tresc" cols="50" rows="14"></textarea>
  21. </td>
  22. </tr>
  23. <tr>
  24. <td align="right" valign="top" class="uni_01">&nbsp;</td>
  25.  
  26. <td class="uni_01">
  27. <input style="font-weight: bold;" type="submit" name="submit" value="submit">
  28. <input type="reset" value="reset"></form>
  29. </td>
  30. </tr>
  31. </table>
  32. <? }
  33. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email'])) {
  34.   $message = '
  35.   Temat: '.$_POST['imie'].'
  36.   Treśc wiadomości: '.$_POST['tresc'].'';
  37.   $header = 'From: '.$_POST['email'].' <'.$_POST['email'].'>';
  38.   @mail("kawex@scores24.net","KaweX.com - ".$_POST['imie']."","$message","$header")
  39.   or die('Nie udalo sie wyslac wiadomości'); ?>
  40.  
  41. <center><font color="#C3A54D">Your email has been sent.<br><br>We will contact you as soon as possible.</font></center>
  42. <script type="text/javascript">setTimeout('window.location.href=http://kawex.com',7000)</script>';
  43. <?
  44. }
  45. else echo '<center><blink><font color="#C3A54D">!!</font></blink> Do not leave any fields blank <blink><font color="#C3A54D">!!</font></blink><br><br>[ <a href="contact">back</a> ] </center>';
  46.  
  47. ?>


Dziala sprawdzane winksmiley.jpg
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.