Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Formularz Kontaktowy...
kkuubbaa88
post 19.11.2007, 23:29:23
Post #1





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


mam sobie formularz:

  1. <?php
  2. if (empty($_POST['submit'])) {
  3.  
  4. echo "<table border=\"0\"><form method=\"post\">
  5. <tr>
  6. ...
  7. ?>


jest i przycisk

  1. <?php
  2. <input type= "submit\" name=\"submit\" value=\"Wyślij\">
  3. ?>


i chcialbym zamienic to sobie na przycisk graficzny... wymacilem kod, ale nie chce dzialac... dlaczego ?

  1. <?php
  2. <input type= "image\" name=\"submit\" src=\"sonda/2.jpg\" onclick=\"submit\">
  3. ?>


po type jest znak \ ale nie chce sie tam wyswietlic tongue.gif
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 15)
Darti
post 19.11.2007, 23:40:45
Post #2





Grupa: Zarejestrowani
Postów: 1 076
Pomógł: 62
Dołączył: 6.03.2005
Skąd: Wroc

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


onclick = 'this.submit()'


--------------------
The answer is out there, Neo. It's looking for you. And it will find you, if you want it to.
SERVER_SOFTWARE : Apache/2.2.4 (Win32) PHP/5.2.1
MySQL Client API version : 5.0.27
Go to the top of the page
+Quote Post
kkuubbaa88
post 20.11.2007, 00:56:59
Post #3





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


niestety nie dziala sad.gif

wie ktos jak przerobic ten kod przycisku, na obrazek ? aby to dzialalo ?
Go to the top of the page
+Quote Post
wojtek.zielinski
post 20.11.2007, 02:08:40
Post #4





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 19.12.2006
Skąd: Poznań

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


Możesz zrobić normalnego submita bez tekstu i z obrazkiem jako tłem:

  1. <input type="submit" value="" style="background-image: image.jpg; width: 100px; heigth: 50px;" />


Oczywiście polecam stosować class zamiast style - tutaj podałem tylko, żeby było wiadomo, o co chodzi


--------------------
Wojtek Zieliński
http://www.zielinscy.pl
php portale cms
Go to the top of the page
+Quote Post
kkuubbaa88
post 20.11.2007, 10:27:31
Post #5





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


to tez nei chce chodzic sad.gif a problemem nie jest to, ze w formie nie ma atrybutu action ? ma to jakiś wpływ ?
Go to the top of the page
+Quote Post
kossa
post 20.11.2007, 10:37:01
Post #6





Grupa: Zarejestrowani
Postów: 1 165
Pomógł: 9
Dołączył: 9.04.2002
Skąd: Toruń

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


Oczywiście, aby wykonał się submit musi być akcja, inaczej jest to nielogiczne, bo gdzie ma form wysłać dane jak nie ma action zadeklarowanej.

Łukasz


--------------------
Go to the top of the page
+Quote Post
Fishu
post 20.11.2007, 10:45:09
Post #7





Grupa: Zarejestrowani
Postów: 192
Pomógł: 13
Dołączył: 16.11.2007
Skąd: Żory

Ostrzeżenie: (10%)
X----


Ja zrobiłem coś takiego: i działa
  1. <input type="image" src="images/submit.gif" />

to zrób też takie coś:
  1. <input type="image" src="sonda/2.jpg" />


Ten post edytował Fishu 20.11.2007, 10:46:27


--------------------
"Źle czynisz, jeśli chwalisz, gorzej, jeśli ganisz rzecz, której dobrze nie znasz." - Leonardo Da Vinci

30.01.2009 - Mój 100 post.
Go to the top of the page
+Quote Post
kkuubbaa88
post 20.11.2007, 10:49:24
Post #8





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


No i nie idzie... sad.gif nic z tych zmian nie wychodzi... nawet nie wiem czemu... jak na chlopski rozum powinno działać... dam cały mój kod kontaktowy to może to coś pomoże. On cały mi działa z tymi przyciskami co sa standardowe... ale graficzne za chiny nie wsadze sad.gif

  1. <?php
  2.  
  3. if (empty($_POST['submit'])) {
  4.  
  5. echo "<table border=\"0\"><form method=\"post\" action=\"kontakt.php\">
  6. <tr height=\"50\"><td></td></tr>
  7. <tr>
  8. <td></td><td></td><td><b>Treść Wiadomości: </b></td><td></td><td></td>
  9. </tr>
  10. <tr>
  11. <td></td>
  12. <td></td><td colspan=\"2\"><textarea name=\"tresc\" style=\"width: 434px; height: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 
  13.  
  14. 1px; border-bottom-width: 1px; border-right-width: 1px; overflow:hidden\" wrap=\"virtual\"></textarea></td><td></td>
  15. </tr>
  16. <tr>
  17. <td></td>
  18. <td style=\"text-align: right\"><b>Imię: </b></td><td><input type=\"text\" name=\"imie\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; 
  19.  
  20. border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td style=\"text-align: right\"><input type=\"text\" name=\"email\" style=\"width: 150px; 
  21.  
  22. border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td><b> :Mail</b></td>
  23. </tr>
  24. <tr height=\"15\"><td width=\"16\"></td><td></td><td></td><td></td><td></td></tr>
  25. <tr>
  26. <td> </td>
  27. <td>
  28. </td><td><input type= \"submit\" name=\"submit\" value=\"Wyślij\"></td><td style=\"text-align: right\"><input type= \"reset\" value=\"Wyczysc\"></td><td></td></form>
  29. </tr>
  30. </table>";
  31. }
  32.  
  33. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email'])) {
  34.  
  35. if (eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+.[a-z]{2,4}$", stripslashes($_POST['email']))){
  36.  
  37.  
  38. $message = "Treść:\n$_POST[tresc]\n\n\nWysłał: $_POST[imie]";
  39.  
  40. $header = "From: $_POST[email] ";
  41.  
  42. @mail("adres","tytul","$message","$header")
  43. or die('Błąd - Spróbuj Ponownie');
  44.  
  45. echo "<span style=\"color: #FF0000; text-align: center;\">Wiadomosc zostala wyslana</span>";
  46. }
  47. else {echo "<span style=\"color: #FF0000; text-align: center;\"></span>";
  48.  
  49. echo "<table border=\"0\"><form method=\"post\">
  50. <tr height=\"50\"><td></td><td colspan=\"4\" style=\"text-align: center\"><span style=\"color: #FF0000; text-align: center;\"><b>Adres e-mail nie jest 
  51.  
  52. poprawny</b></span></td></tr>
  53. <tr>
  54. <td></td><td></td><td><b>Treść Wiadomości: </b></td><td></td><td></td>
  55. </tr>
  56. <tr>
  57. <td></td>
  58. <td></td><td colspan=\"2\"><textarea name=\"tresc\" style=\"width: 434px; height: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 
  59.  
  60. 1px; border-bottom-width: 1px; border-right-width: 1px; overflow:hidden\" wrap=\"virtual\"></textarea></td><td></td>
  61. </tr>
  62. <tr>
  63. <td></td>
  64. <td style=\"text-align: right\"><b>Imię: </b></td><td><input type=\"text\" name=\"imie\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; 
  65.  
  66. border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td style=\"text-align: right\"><input type=\"text\" name=\"email\" style=\"width: 150px; 
  67.  
  68. border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td><b> :Mail</b></td>
  69. </tr>
  70. <tr height=\"15\"><td width=\"16\"></td><td></td><td></td><td></td><td></td></tr>
  71. <tr>
  72. <td> </td>
  73. <td>
  74. </td><td><input type= \"submit\" name=\"submit\" value=\"Wyślij\"></td><td style=\"text-align: right\"><input type= \"reset\" value=\"Wyczysc\"></td><td></td></form>
  75. </tr>
  76. </table>";
  77. }
  78.  
  79. }
  80.  
  81. else {
  82. echo "<table border=\"0\"><form method=\"post\">
  83. <tr height=\"50\"><td></td><td colspan=\"4\" style=\"text-align: center\"><span style=\"color: #FF0000; text-align: center;\"><b>Wszystkie pola są obowiązkowe</b></span></td></tr>
  84. <tr>
  85. <td></td><td></td><td><b>Treść Wiadomości: </b></td><td></td><td></td>
  86. </tr>
  87. <tr>
  88. <td></td>
  89. <td></td><td colspan=\"2\"><textarea name=\"tresc\" style=\"width: 434px; height: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 
  90.  
  91. 1px; border-bottom-width: 1px; border-right-width: 1px; overflow:hidden\" wrap=\"virtual\"></textarea></td><td></td>
  92. </tr>
  93. <tr>
  94. <td></td>
  95. <td style=\"text-align: right\"><b>Imię: </b></td><td><input type=\"text\" name=\"imie\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; 
  96.  
  97. border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td style=\"text-align: right\"><input type=\"text\" name=\"email\" style=\"width: 150px; 
  98.  
  99. border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td><b> :Mail</b></td>
  100. </tr>
  101. <tr height=\"15\"><td width=\"16\"></td><td></td><td></td><td></td><td></td></tr>
  102. <tr>
  103. <td> </td>
  104. <td>
  105. </td><td><input type= \"submit\" name=\"submit\" value=\"Wyślij\"></td><td style=\"text-align: right\"><input type= \"reset\" value=\"Wyczysc\"></td><td></td></form>
  106. </tr>
  107. </table>";
  108. }
  109.  
  110.  
  111. ?>


Ten post edytował kkuubbaa88 20.11.2007, 10:57:24
Go to the top of the page
+Quote Post
Sadu2
post 20.11.2007, 12:01:36
Post #9





Grupa: Zarejestrowani
Postów: 229
Pomógł: 13
Dołączył: 31.05.2007

Ostrzeżenie: (10%)
X----


Czy może o to Ci chodziło?

http://tafclan.com/test.php

  1. <?php
  2. <input type=&#092;"submit\" name=\"submit\" style=\"background-image: url('submit.gif'); width: 78px; height: 28px; border:0px solid;\" value=\"\"/>
  3. ?>


Tam musisz wprowadzić szerokość i wysokość obrazka. Pole value zostaw puste.


Całość:

  1. <?php
  2. if (empty($_POST['submit'])) {
  3.  
  4. echo "<table border=\"0\"><form method=\"post\" action=\"kontakt.php\">
  5. <tr height=\"50\"><td></td></tr>
  6. <tr><td></td>
  7. <td></td>";
  8.  
  9. echo "<td><b>Treść Wiadomości: </b></td>
  10. <td></td>
  11. <td></td>
  12. </tr><tr>
  13. <td></td>";
  14.  
  15. echo "<td></td><td colspan=\"2\"><textarea name=\"tresc\" style=\"width: 434px; height: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px; overflow:hidden\" wrap=\"virtual\"></textarea>";
  16.  
  17. echo "</td><td>
  18. </td></tr><tr><td></td>
  19. <td style=\"text-align: right\"><b>Imię: </b></td><td><input type=\"text\" name=\"imie\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td style=\"text-align: right\"><input type=\"text\" name=\"email\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td><b> :Mail</b></td>";
  20.  
  21. echo "</tr><tr height=\"15\"><td width=\"16\"></td><td></td><td></td><td></td><td></td></tr><tr><td> </td><td></td>";
  22.  
  23. echo "<td><input type=\"submit\" name=\"submit\" style=\"background-image: url('submit.gif'); width: 78px; height: 28px; border:0px solid;\" value=\"\"/></td><td style=\"text-align: right\"><input type = \"reset\" value=\"Wyczysc\"></td><td></td></form></tr></table>";
  24. }
  25.  
  26. elseif (!empty($_POST['tresc']) && !empty($_POST['imie']) && !empty($_POST['email'])) {
  27.  
  28. if (eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+.[a-z]{2,4}$", stripslashes($_POST['email']))){
  29.  
  30.  
  31. $message = "Treść:\n$_POST[tresc]\n\n\nWysłał: $_POST[imie]";
  32.  
  33. $header = "From: $_POST[email] ";
  34.  
  35. @mail("adres","tytul","$message","$header")
  36. or die('Błąd - Spróbuj Ponownie');
  37.  
  38. echo "<span style=\"color: #FF0000; text-align: center;\">Wiadomosc zostala wyslana</span>";
  39. } else {
  40. echo "<span style=\"color: #FF0000; text-align: center;\"></span>";
  41.  
  42. echo "<table border=\"0\"><form method=\"post\"><tr height=\"50\"><td></td><td colspan=\"4\" style=\"text-align: center\"><span style=\"color: #FF0000; text-align: center;\"><b>Adres e-mail nie jest poprawny</b></span></td></tr>";
  43.  
  44. echo "<tr><td></td><td></td><td><b>Treść Wiadomości: </b></td><td></td><td></td></tr><tr><td></td><td></td><td colspan=\"2\"><textarea name=\"tresc\" style=\"width: 434px; height: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px; overflow:hidden\" wrap=\"virtual\"></textarea></td><td></td>";
  45.  
  46. echo "</tr><tr><td></td><td style=\"text-align: right\"><b>Imię: </b></td><td><input type=\"text\" name=\"imie\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td style=\"text-align: right\"><input type=\"text\" name=\"email\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td><b> :Mail</b></td></tr>";
  47.  
  48. echo "<tr height=\"15\"><td width=\"16\"></td><td></td><td></td><td></td><td></td></tr><tr><td> </td><td></td><td><input type= \"submit\" name=\"submit\" value=\"Wyślij\"></td><td style=\"text-align: right\"><input type= \"reset\" value=\"Wyczysc\"></td><td></td></form></tr></table>";
  49. }
  50.  
  51. } else {
  52.  
  53. echo "<table border=\"0\"><form method=\"post\">
  54. <tr height=\"50\"><td></td><td colspan=\"4\" style=\"text-align: center\"><span style=\"color: #FF0000; text-align: center;\"><b>Wszystkie pola są obowiązkowe</b></span></td></tr>";
  55.  
  56. echo "<tr><td></td><td></td><td><b>Treść Wiadomości: </b></td><td></td><td></td></tr><tr><td></td><td></td><td colspan=\"2\"><textarea name=\"tresc\" style=\"width: 434px; height: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px; overflow:hidden\" wrap=\"virtual\"></textarea></td><td></td></tr>";
  57.  
  58. echo "<tr><td></td><td style=\"text-align: right\"><b>Imię: </b></td><td><input type=\"text\" name=\"imie\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td style=\"text-align: right\"><input type=\"text\" name=\"email\" style=\"width: 150px; border-style: double; border-color: #6eb4d8; border-top-width: 1px ; border-left-width: 1px; border-bottom-width: 1px; border-right-width: 1px\"></td><td><b> :Mail</b></td></tr>";
  59.  
  60. echo "<tr height=\"15\"><td width=\"16\"></td><td></td><td></td><td></td><td></td></tr><tr><td> </td><td></td><td><input type= \"submit\" name=\"submit\" value=\"Wyślij\"></td><td style=\"text-align: right\"><input type= \"reset\" value=\"Wyczysc\"></td><td></td></form></tr></table>";
  61. }
  62. ?>


Ten post edytował Sadu2 20.11.2007, 12:15:17
Go to the top of the page
+Quote Post
kkuubbaa88
post 20.11.2007, 12:35:00
Post #10





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


tak dokladnie o to mi chodzi... wszystko ladnie jest. przycisk sie pokazuje, ale on nie dziala sad.gif po kliknieciu nic sie nie dzieje sad.gif nie rozumie w ogole dlaczego...
Go to the top of the page
+Quote Post
Sadu2
post 20.11.2007, 12:46:15
Post #11





Grupa: Zarejestrowani
Postów: 229
Pomógł: 13
Dołączył: 31.05.2007

Ostrzeżenie: (10%)
X----


Poczytaj tu:

http://pl2.php.net/function.mail
Go to the top of the page
+Quote Post
nospor
post 20.11.2007, 12:53:07
Post #12





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




if (empty($_POST['submit']))

Przeciez ten warunek po wyslaniu tego submita bedzie prawdziwy, bo submit nie ma wartosc. Powinno byc:
if (!isset($_POST['submit']))


Podobnie gdy byl type="image". Taki typ nie wysyla postem nazwy, tylko nazwa_x oraz nazwa_y, czyli dla image powinno byc:
if (!isset($_POST['submit_x']))


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
kkuubbaa88
post 20.11.2007, 13:23:56
Post #13





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


wlasnie mialem mowic, ze przycisk mi nie zwraca nic i jest problem z warunkiem... to przepraszam jak ma byc jesli jest image ?

  1. <?php
  2. <input type=&#092;"image\" src=\"mail/wyslij.jpg\" onclick=\"submit\">
  3. ?>


jak powinien wygladac warunek ? bo nie bardzo wiem o co chodzi z tymi nazwa_x i nazwa_y ?
Go to the top of the page
+Quote Post
nospor
post 20.11.2007, 13:26:59
Post #14





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




No przeciez ci podalem:
if (!isset($_POST['submit_x']))

Tylko dla tego pola image nadaj name="submit" a te onclick wywal bo jest zupelnie zbedne. Image sam submituje bez zadnej pomocy


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
kkuubbaa88
post 20.11.2007, 14:43:27
Post #15





Grupa: Zarejestrowani
Postów: 510
Pomógł: 1
Dołączył: 27.08.2007

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


no i w koncu wszystko dziala jak powinno smile.gif dzieki smile.gif

jeszcze tylko pytanie z ciekawosci... dlaczego w submit musi byc to _x ? co to oznacza ?
Go to the top of the page
+Quote Post
nospor
post 20.11.2007, 14:52:40
Post #16





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




Cytat
dlaczego w submit musi byc to _x
z tego samego powodu co ptak lata: bo tak.

Tak jest zrobione, ze submity typu image wysylaja postem nie "nazwa" a "nazwa_x" oraz "nazwa_y", ktore zawiera wspólrzedne klikniecia.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 10:27