Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Fromularz wysyła dane ale ich nie przetwarza
bartkow
post
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


Witam serdecznie!

Miałem nadzieję, że nie będę wam zawracać głowy, ale od kilkunastu minut próbuje, przyglądam się, staje na głowie a to nie działa.

Chodzi o formularz, który działa w jednym pliku PHP. Wstawiony jest do innej strony (podstrony) (ten sam katalog) za pomocą require.

Kod w wersji okrojonej:

  1. if (empty($_POST['submit'])) {
  2.  
  3. echo "
  4. <form actions='' method='post' autocomplete='off'>
  5.  
  6. <table border='0' cellpadding='2' cellspacing='2'>
  7. <tr>
  8. <td>Name & Surname &nbsp;&nbsp;</td>
  9. <td><input name='imie' type='text' size='40' value='$name'/></td>
  10. </tr>
  11. <tr>
  12. <td>Your E-mail</td>
  13. <td><input name='email' size='40' type='text' /></td>
  14. </tr>
  15. <tr>
  16. <td>Subject</td>
  17. <td><input name='sub' size='40' type='text' /></td>
  18. </tr>
  19. <tr>
  20. <td>Message</td>
  21. <td><textarea name='tresc' cols='55' rows='12'></textarea></td>
  22. </tr>
  23. </table>
  24.  
  25. <input type='submit' class='button button-icon button-icon-rarrow' value='Create ticket'>
  26.  
  27. </form>
  28. ";
  29. }
  30.  
  31. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['sub']) ) {
  32.  
  33. ////JAKIEŚ DZIAŁANIE////
  34.  
  35.  
  36. }
  37.  
  38. else echo "<a href='java script:history.back()'><img src='./images/error-all.png' witdh='600' height='300'></a>";
  39.  
  40.  
  41.  


Zastosowałem funkcję print_r($_POST);
formularz wysyła dane:
Array ( [imie] => imie i nazwisko [email] => email [sub] => temat [tresc] => tresc )

Proszę o pomoc
Go to the top of the page
+Quote Post
2 Stron V   1 2 >  
Start new topic
Odpowiedzi (1 - 19)
com
post
Post #2





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


nie napisałeś najważniejszego w czym jest problem??
Go to the top of the page
+Quote Post
bartkow
post
Post #3





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


O właśnie zapomniałem.

Nie przetwarza danych, po prostu nie dzieje się nic, tj usuwa tylko dane z formularza

Ten post edytował bartkow 26.09.2013, 20:35:33
Go to the top of the page
+Quote Post
com
post
Post #4





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


Kod
    ////JAKIEŚ DZIAŁANIE////


no bo tam gdzie ma coś robić nic nie ma ;>
Go to the top of the page
+Quote Post
bartkow
post
Post #5





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


nie chcę wypisywać co tam jest, ale to kiedyś działało może tak.

W skrócie wysyła e-mail, i powinien nie wyświetlać formularza, tylko komunikat.

A tak to zostaje i formularz i nic sie nie dzieje

Ten post edytował bartkow 26.09.2013, 20:35:56
Go to the top of the page
+Quote Post
com
post
Post #6





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


może to to :
  1. <input type="submit" name="submit" class='button button-icon button-icon-rarrow' value='Create ticket' />

i raczej tak
  1. if(isset($_POST['submit'])) { ... }


a tak wgl to jasnowidzem nie jestem (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post
bartkow
post
Post #7





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


Taki przykład.

print_r($_POST); pokazuje wszystko ok, ale reszta nie działa
  1. if (empty($_POST['submit'])) {
  2.  
  3. echo "
  4. <form actions='' method='post' autocomplete='off'>
  5.  
  6. <table border='0' cellpadding='2' cellspacing='2'>
  7. <tr>
  8. <td>Name & Surname   </td>
  9. <td><input name='imie' type='text' size='40' value='$name'/></td>
  10. </tr>
  11. <tr>
  12. <td>Your E-mail</td>
  13. <td><input name='email' size='40' type='text' /></td>
  14. </tr>
  15. <tr>
  16. <td>Subject</td>
  17. <td><input name='sub' size='40' type='text' /></td>
  18. </tr>
  19. <tr>
  20. <td>Message</td>
  21. <td><textarea name='tresc' cols='55' rows='12'></textarea></td>
  22. </tr>
  23. </table>
  24.  
  25. <input type='submit' class='button button-icon button-icon-rarrow' value='Create ticket'>
  26.  
  27. </form>
  28. ";
  29. }
  30.  
  31. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['sub']) ) {
  32.  
  33. echo ("$_POST[imie]");
  34.  
  35.  
  36.  
  37. }
  38.  
  39. else echo "<a href='java script:history.back()'><img src='./images/error-all.png' witdh='600' height='300'></a>";
  40.  
  41.  


Ten post edytował bartkow 26.09.2013, 20:45:42
Go to the top of the page
+Quote Post
japan13
post
Post #8





Grupa: Zarejestrowani
Postów: 23
Pomógł: 2
Dołączył: 31.10.2008

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


  1. <?php
  2. if (empty($_POST['submit'])) {
  3.  
  4. <form actions='' method='post' autocomplete='off'>
  5.  
  6. <table border='0' cellpadding='2' cellspacing='2'>
  7. <tr>
  8. <td>Name & Surname &nbsp;&nbsp;</td>
  9. <td><input name='imie' type='text' size='40' value='$name'/></td>
  10. </tr>
  11. <tr>
  12. <td>Your E-mail</td>
  13. <td><input name='email' size='40' type='text' /></td>
  14. </tr>
  15. <tr>
  16. <td>Subject</td>
  17. <td><input name='sub' size='40' type='text' /></td>
  18. </tr>
  19. <tr>
  20. <td>Message</td>
  21. <td><textarea name='tresc' cols='55' rows='12'></textarea></td>
  22. </tr>
  23. </table>
  24.  
  25. <input type='submit' name='submit' class='button button-icon button-icon-rarrow' value='Create ticket'>
  26.  
  27. </form>
  28. ";
  29. }
  30.  
  31. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['sub']) ) {
  32.  
  33. $_POST[imie],
  34. $_POST[sub]";
  35.  
  36.  
  37.  
  38. }
  39.  
  40. else echo "<a href='java script:history.back()'><img src='./images/error-all.png' witdh='600' height='300'></a>";
  41. ?>



Poprawiłem, działa spradzałem. Mam nadzieję że pomogłem (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
com
post
Post #9





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


  1. echo "
  2. $_POST[imie],
  3. $_POST[sub]";

no chyba nie (IMG:style_emoticons/default/smile.gif)
jak już to tak
  1. echo $_POST['imie'].','.$_POST['sub'];

a spróbowałeś zmienić to co napisałem ? (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post
bartkow
post
Post #10





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


Taki błąd, nawet
echo("działam");
nie daje rezultatu
Go to the top of the page
+Quote Post
japan13
post
Post #11





Grupa: Zarejestrowani
Postów: 23
Pomógł: 2
Dołączył: 31.10.2008

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


Fakt, kolega ma rację dodaj tam konkatenacje.

Nie daje gdyż echo nie jest funkcją (IMG:style_emoticons/default/smile.gif) Uwierz mi że taki kod: <? echo "fsdfsdfsadf"; ?> da już rezultat (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
bartkow
post
Post #12





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


Cytat(japan13 @ 26.09.2013, 21:47:42 ) *
  1. <?php
  2. if (empty($_POST['submit'])) {
  3.  
  4. <form actions='' method='post' autocomplete='off'>
  5.  
  6. <table border='0' cellpadding='2' cellspacing='2'>
  7. <tr>
  8. <td>Name & Surname &nbsp;&nbsp;</td>
  9. <td><input name='imie' type='text' size='40' value='$name'/></td>
  10. </tr>
  11. <tr>
  12. <td>Your E-mail</td>
  13. <td><input name='email' size='40' type='text' /></td>
  14. </tr>
  15. <tr>
  16. <td>Subject</td>
  17. <td><input name='sub' size='40' type='text' /></td>
  18. </tr>
  19. <tr>
  20. <td>Message</td>
  21. <td><textarea name='tresc' cols='55' rows='12'></textarea></td>
  22. </tr>
  23. </table>
  24.  
  25. <input type='submit' name='submit' class='button button-icon button-icon-rarrow' value='Create ticket'>
  26.  
  27. </form>
  28. ";
  29. }
  30.  
  31. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['sub']) ) {
  32.  
  33. $_POST[imie],
  34. $_POST[sub]";
  35.  
  36.  
  37.  
  38. }
  39.  
  40. else echo "<a href='java script:history.back()'><img src='./images/error-all.png' witdh='600' height='300'></a>";
  41. ?>



Poprawiłem, działa spradzałem. Mam nadzieję że pomogłem (IMG:style_emoticons/default/smile.gif)



Array ( [imie] => gfg [email] => fdghdf [sub] => fghfg [tresc] => hfghftg [submit] => )

i daje bez zmian
Go to the top of the page
+Quote Post
japan13
post
Post #13





Grupa: Zarejestrowani
Postów: 23
Pomógł: 2
Dołączył: 31.10.2008

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


A jeśli w echo chcesz wstawić jeszcze jakąś zmienną skorzystaj z konkatenacji (łączenie stringow) tzn:

  1. <?php
  2.  
  3. echo "jakiś tekst ".$zmienna."jakiś test".$zmienna2;
  4. ?>
Go to the top of the page
+Quote Post
com
post
Post #14





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


japan13 jak nie wiesz to nie mów takich głupot http://ideone.com/ZxG0yB (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
bartkow
post
Post #15





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


Hmm.
Wszedłem na adres docelowy tj np. localhost/dodaj.php i tam działa znakomicie, natomiast jak w index.php jest wstaione jako require("dodaj.php"), to juz nie (IMG:style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
com
post
Post #16





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


  1. if(isset($_POST['submit'])) {
  2.  
  3. <form actions='' method='post' autocomplete='off'>
  4.  
  5. <table border='0' cellpadding='2' cellspacing='2'>
  6. <tr>
  7. <td>Name & Surname &nbsp;&nbsp;</td>
  8. <td><input name='imie' type='text' size='40' value='$name'/></td>
  9. </tr>
  10. <tr>
  11. <td>Your E-mail</td>
  12. <td><input name='email' size='40' type='text' /></td>
  13. </tr>
  14. <tr>
  15. <td>Subject</td>
  16. <td><input name='sub' size='40' type='text' /></td>
  17. </tr>
  18. <tr>
  19. <td>Message</td>
  20. <td><textarea name='tresc' cols='55' rows='12'></textarea></td>
  21. </tr>
  22. </table>
  23.  
  24. <input type="submit" name="submit" class='button button-icon button-icon-rarrow' value='Create ticket' />
  25.  
  26. </form>
  27. ";
  28. }
  29.  
  30. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['sub']) ) {
  31.  
  32. ////JAKIEŚ DZIAŁANIE////
  33.  
  34.  
  35. }
  36.  
  37. else echo "<a href='java script:history.back()'><img src='./images/error-all.png' witdh='600' height='300'></a>";
  38.  
  39.  

tak masz?

  1. <form actions='dodaj.php' method='post' autocomplete='off'>
Go to the top of the page
+Quote Post
japan13
post
Post #17





Grupa: Zarejestrowani
Postów: 23
Pomógł: 2
Dołączył: 31.10.2008

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


com, faktycznie działa (IMG:style_emoticons/default/smile.gif) Nigdy jeszcze nie spotkałem się z zapisem echo("afF"); w PHP'ie (IMG:style_emoticons/default/biggrin.gif) To taki bardziej Pythonowy zapis (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
com
post
Post #18





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


bo skoro go dołączasz do indexu to bez ustawienia actions wysyłasz do pliku index.php a nie do dodaj.php (IMG:style_emoticons/default/smile.gif)

japan13 widać jesteś młodym pechapowcem, tak się robiło wersjach <= 4 (IMG:style_emoticons/default/wink.gif) , a potem przyjęło się pomijać nawiasy (IMG:style_emoticons/default/biggrin.gif)

w Pythonie nie masz echo tylko print i też jest print "cos" tyle ze bez średnika na końcu (IMG:style_emoticons/default/tongue.gif)

Btw echo jest funkcją (IMG:style_emoticons/default/smile.gif) http://php.net/manual/en/function.echo.php

Ten post edytował com 26.09.2013, 21:07:34
Go to the top of the page
+Quote Post
bartkow
post
Post #19





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 26.09.2013

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


Powiem tak, jeśli zrobię tak jak com, to nie wyświetla nic

2) Skopiowalem wsyzstko z dodaj.php do index.php i nic nie robi, a jak otworze sam dodaj.php to działa elegancko (mowa o mojej pierwszej wersji)


/Edit

Powiem tak, kiedyś to działało. Postanowiłem zmienić wygląd strony, dodać jquery jako wygląd pól i siadło

Ten post edytował bartkow 26.09.2013, 21:33:00
Go to the top of the page
+Quote Post
com
post
Post #20





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


index.php
  1. require("dodaj.php");

dodaj.php
  1. if(!isset($_POST['submit'])) {
  2. $name = "x";
  3. <form actions='' method='post' autocomplete='off'>
  4.  
  5. <table border='0' cellpadding='2' cellspacing='2'>
  6. <tr>
  7. <td>Name & Surname &nbsp;&nbsp;</td>
  8. <td><input name='imie' type='text' size='40' value='$name'/></td>
  9. </tr>
  10. <tr>
  11. <td>Your E-mail</td>
  12. <td><input name='email' size='40' type='text' /></td>
  13. </tr>
  14. <tr>
  15. <td>Subject</td>
  16. <td><input name='sub' size='40' type='text' /></td>
  17. </tr>
  18. <tr>
  19. <td>Message</td>
  20. <td><textarea name='tresc' cols='55' rows='12'></textarea></td>
  21. </tr>
  22. </table>
  23.  
  24. <input type='submit' name='submit' class='button button-icon button-icon-rarrow' value='Create ticket' />
  25.  
  26. </form>
  27. ";
  28. }
  29.  
  30. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email']) && !empty($_POST['sub']) ) {
  31.  
  32. echo "ok";
  33.  
  34.  
  35. }
  36.  
  37. else echo "<a href='java script:history.back()'><img src='./images/error-all.png' witdh='600' height='300'></a>";
  38.  


tak bo zrobiłem tam błąd zapomniałem o ! (IMG:style_emoticons/default/wink.gif)

działa bo sprawdziłem (IMG:style_emoticons/default/smile.gif) a jak u Ciebie dalej nie to nie tu tkwi błąd (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
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: 15.09.2025 - 15:51