Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Modyfikacja skryptu kontakt - dodanie wyboru tematów
-asziatko-
post
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
 
Start new topic
Odpowiedzi
sebekzosw
post
Post #2





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 (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
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: 6.10.2025 - 19:09