Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Modyfikacja skryptu kontakt - dodanie wyboru tematów
-asziatko-
post 8.10.2008, 18:49:10
Post #1





Goście







Witam,

Mam taki formularz kontaktowy jak poniżej

<?php
if(strlen($_POST['nazwa']) < 5){
header('Location: kontakt.php?msg=nazwa');
exit;
}
if(strlen($_POST['mail']) < 5){
header('Location: kontakt.php?msg=mail');
exit;
}
if(strlen($_POST['imie']) <= 3){
header('Location: kontakt.php?msg=imie');
exit;
}
if(strlen($_POST['tresc']) < 5){
header('Location: kontakt.php?msg=tresc');
exit;
}
if(isSet($_COOKIE['antyflood'])){
header('Location: kontakt.php?msg=flood');
exit;
}
$data = date("d - m - Y");
$tresc2 = strip_tags($_POST['tresc']);
$naglowki = "From: ".$_POST['imie']."\r\n";
$naglowki = "Reply-To: ".$_POST['mail']."\r\n";
$temat1 = $_POST['imie'];
$temat = 'E-Mail Ze Strony Www;
$ip = $_SERVER['REMOTE_ADDR'];
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);

$tresc = "Nadawca: $_POST[imie]
Wysłany Dnia: $data
Temat: $_POST[nazwa]
E-Mail Nadawcy: $_POST[mail]
Napisano: \r\n\r\n $tresc2 \r\n\r\n
Wiadomość Wysłana z Komputera o Numerze IP: $ip i HOST: $host";

$i = @mail([email=""]'email'[/email], $temat, trim($tresc), $naglowki);

if($i===TRUE){
setcookie('antyflood', 'bu', time()+60);
header('Location: kontakt.php?msg=ok');
exit;
}
if($i===FALSE){
header('Location: kontakt.php?msg=no');
exit;
}
?>

Chciał bym w tym formularzu dodać możliwość wyboru tematów z listy rozwijanej np.

Temat 1
Temat 2
Temat 3
Temat 4

w pliku kontakt.php część kodu odpowiadająca aktualnie za wyświetlenie pola do wpisania tematu wygląda tak

  1. <tr>
  2. <td><strong>Temat:</strong></td>
  3. <td><input class="pole" type="text" name="nazwa" size="30" title="Wpisz Temat" maxlength="50" /></td>
  4. </tr>


Jak zmodyfikować powyższy kod żeby można było wybierać tematy e-maila z listy?.

Ten post edytował asziatko 8.10.2008, 18:51:42
Go to the top of the page
+Quote Post
batman
post 8.10.2008, 18:57:29
Post #2





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




@asziatko Dodaj poprawny bbcode.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
sebekzosw
post 8.10.2008, 19:08:17
Post #3





Grupa: Zarejestrowani
Postów: 437
Pomógł: 42
Dołączył: 16.04.2007

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


  1. <tr>
  2. <td><strong>Temat:</strong></td>
  3. <td>
  4. <select size="1" name="temat">
  5. <option value="topic_1">Temat 1</option>
  6. <option value="topic_2">Temat 2</option>
  7. </select>
  8. </td>
  9. </tr>



  1. <?php
  2. if(strlen($_POST['nazwa']) < 5){
  3.    header('Location: kontakt.php?msg=nazwa');
  4.    exit;
  5. }
  6.  
  7. if(strlen($_POST['mail']) < 5){
  8.    header('Location: kontakt.php?msg=mail');
  9.    exit;
  10. }
  11.  
  12. if(strlen($_POST['imie']) <= 3){
  13.     header('Location: kontakt.php?msg=imie');
  14.     exit;
  15. }
  16.  
  17. if(strlen($_POST['tresc']) < 5){
  18.     header('Location: kontakt.php?msg=tresc');
  19.     exit;
  20. }
  21.  
  22. if(isset($_COOKIE['antyflood'])){
  23.     header('Location: kontakt.php?msg=flood');
  24.     exit;
  25. }
  26.  
  27. $data = date("d - m - Y");
  28. $tresc2 = strip_tags($_POST['tresc']);
  29. $naglowki = "From: ".$_POST['imie']."r\n";
  30. $naglowki = "Reply-To: ".$_POST['mail']."r\n";
  31. $temat1 = $_POST['imie'];
  32. $temat = $_POST['temat'];
  33. $ip = $_SERVER['REMOTE_ADDR'];
  34. $host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
  35.  
  36. $tresc = "Nadawca: ".$_POST['imie']."
  37. Wysłany Dnia: ".$data."
  38. Temat: ".$_POST['nazwa']."
  39. E-Mail Nadawcy: ".$_POST['mail']."
  40. Napisano: r\nr\n ".$tresc2." r\nr\n
  41. Wiadomość Wysłana z Komputera o Numerze IP: ".$ip." i HOST: ".$host."";
  42.  
  43. $i = @mail([email=""]'email'[/email], $temat, trim($tresc), $naglowki);
  44.  
  45. if($i===TRUE){
  46.     setcookie('antyflood', 'bu', time()+60);
  47.     header('Location: kontakt.php?msg=ok');
  48.    exit;
  49. } else {
  50.    header('Location: kontakt.php?msg=no');
  51.    exit;
  52. }
  53. ?>

Mam nadzieje, że sobie poradzisz smile.gif
Go to the top of the page
+Quote Post
-asziatko-
post 10.01.2009, 09:22:12
Post #4





Goście







Próbowałem zmodyfikować skrypt formularza kontakt tak żeby dodać wybór tematów ale nic z tego... . Może jeszcze jakieś wskazówki rolleyes.gif ?.
Go to the top of the page
+Quote Post
pawel81
post 10.01.2009, 10:20:22
Post #5





Grupa: Zarejestrowani
Postów: 110
Pomógł: 13
Dołączył: 28.04.2007

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


Zamien to
  1. <tr>
  2. <td><strong>Temat:</strong></td>
  3. <td><input class="pole" type="text" name="nazwa" size="30" title="Wpisz Temat" maxlength="50" /></td>
  4. </tr>


na to

  1. <tr>
  2. <td><strong>Temat:</strong></td>
  3. <td>
  4. <select size="1" name="temat">
  5. <option value="topic_1">Temat 1</option>
  6. <option value="topic_2">Temat 2</option>
  7. </select>
  8. </td>
  9. </tr>


Zobacz tutaj http://www.kurshtml.boo.pl/html/lista_rozw...formularze.html

Ten post edytował pawel81 10.01.2009, 10:24:34
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: 31.07.2025 - 09:54