PHP Formular mit Upload-Funktion

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • PHP Formular mit Upload-Funktion

    Moin,

    mit Hilfe von etlichen Formmailern und SELFHTML habe ich mir ein reines PHP-Formular gebastelt.

    Bedingungen waren: PHP, Dropdown-Felder, ein Upload-Feld und das ganze sollte an eine Email Adresse gesendet werden.

    Klappt soweit ganz gut, außer das in der Mail das Dropdown-Feld mit einer 0 gesendet wird und das Upload-Feld funzt nicht.

    Ich notiere hier mal den relevanten Auszug des Scripts. Vielleicht kommt von Euch jemand dahinter.......

    Quellcode

    1. <?php
    2. $strEmpfaenger = 'empfaenger@domain.de';
    3. $strFrom = '"Artikelerstellung" <absender@domain.de>';
    4. $strSubject = 'neuer Artikel';
    5. $strReturnhtml = 'http://www.test.de/artikel.php';
    6. $strDelimiter = ":\t";
    7. if($_POST)
    8. {
    9. if($_POST['Shopname'])
    10. {
    11. $strMailtext = "";
    12. while(list($strName,$value) = each($_POST))
    13. {
    14. if(is_array($value))
    15. {
    16. foreach($value as $value_array)
    17. {
    18. $strMailtext .= $strName.$strDelimiter.$value_array."\n";
    19. }
    20. }
    21. else
    22. {
    23. $strMailtext .= $strName.$strDelimiter.$value."\n";
    24. }
    25. }
    26. }
    27. else die('Sie haben den Shopnamen vergessen');
    28. if(get_magic_quotes_gpc())
    29. {
    30. $strMailtext = stripslashes($strMailtext);
    31. }
    32. mail($strEmpfaenger, $strSubject, $strMailtext, "From: ".$strFrom)
    33. or die("Die Mail konnte nicht versendet werden.");
    34. header("Location: $strReturnhtml");
    35. exit;
    36. }
    37. ?>
    38. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    39. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
    40. <head>
    41. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    42. <meta http-equiv="content-language" content="de-DE" />
    43. <title>Artikelerstellung</title>
    44. <link href="css/form.css" rel="stylesheet" type="text/css" />
    45. <link rel="stylesheet" TYPE="text/css" href="style.css" media="screen" />
    46. <meta http-equiv="Page-Enter" content="RevealTrans(Duration=2,Transition=12)" />
    47. <meta http-equiv="Page-Exit" content="RevealTrans(Duration=2,Transition=12)" />
    48. </head>
    49. <body>
    50. <div id="main_schatten">
    51. <div id="inner">
    52. <div id="urltext"><a href="index.html" class="navigurl" title="zurück zur Hauptseite...">index » </a>Eingabe</div>
    53. <form enctype="multipart/form-data" action="<?php echo htmlspecialchars ($_SERVER['PHP_SELF']); ?>" method="post">
    54. <!-- *** SHOPNAME: *** -->
    55. <div style="position:absolute;left:10px;top:44px;width:180px;height:18px;font:0.8em Trebuchet MS,Arial;font-weight:normal;font-style:normal;text-decoration:none;color:#D8D8D8;background:transparent;">Artikeleingabe f&uuml;r Online-Shop</div>
    56. <input type="text" name="Shopname" style="position:absolute;left:200px;top:44px;width:150px;height:14px;font:0.8em Trebuchet MS,Arial;font-weight:normal;font-style:normal;text-decoration:none;color:#000000;background:#D8D8D8;border: 1px solid #000000;" />
    57. <!-- *** GESCHMACK *** -->
    58. <div style="position:absolute;left:426px;top:236px;width:72px;height:18px;font:0.8em Trebuchet MS,Arial;font-weight:normal;font-style:normal;text-decoration:none;color:#D8D8D8;background:transparent;">Geschmack</div>
    59. <select name="Geschmack" style="position:absolute;left:502px;top:234px;width:102px;height:21px;font:0.8em Trebuchet MS,Arial;font-weight:normal;font-style:normal;text-decoration:none;color:#000000;background:#D8D8D8;border: 1px solid #000000;">
    60. <?php
    61. $selected = ($idx == '0') ? 'selected="selected"' : '';
    62. echo("\n".'<option value="0" '.$selected.'>w&auml;hlen</option>');
    63. $selected = ($idx == '1') ? 'selected="selected"' : '';
    64. echo("\n".'<option value="1" '.$selected.'>trocken</option>');
    65. $selected = ($idx == '2') ? 'selected="selected"' : '';
    66. echo("\n".'<option value="2" '.$selected.'>halbtrocken</option>');
    67. ?></select>
    68. <!-- *** UPLOADFELD *** -->
    69. <div style="position:absolute;left:10px;top:409px;width:188px;height:18px;font:0.8em Trebuchet MS,Arial;font-weight:normal;font-style:normal;text-decoration:none;color:#D8D8D8;background:transparent;">Artikelbild oder Datei hochladen:</div>
    70. <input type="file" name="senden" style="position:absolute;left:221px;top:408px;width:384px;height:20px;font:0.8em Trebuchet MS,Arial;font-weight:normal;font-style:normal;text-decoration:none;color:#000000;background:#D8D8D8;border: 1px solid #000000;" />
    71. </form>
    72. </div>
    73. </div>
    74. </body>
    75. </html>
    Alles anzeigen


    Gruß, Krischan