Formular mit Anhnag versenden aber wie?

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

    • Formular mit Anhnag versenden aber wie?

      Hallo alle,

      bin gerade dabei ein Formular zu programmieren, hier der HTML Code dafür:

      HTML-Quellcode

      1. <!DOCTYPE html>
      2. <html>
      3. <head>
      4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      5. <title>Sign-Line Formular</title>
      6. <style>
      7. body {font-family:Arial;font-size:12px;}
      8. input, label {display:inline-block;}
      9. label {cursor:pointer;}
      10. h1, h2, h3 {color:#e3001b;}
      11. </style>
      12. </head>
      13. <body>
      14. <form action="" method="POST">
      15. <span>Hier können Sie Ihre <strong>Fragen & Veredelungswünsche</strong></span><br />
      16. <span><label for="artikelname">zum folgenden Artikel stellen:</label></span>
      17. <input id="artikelname" type="text" name="Artikelname" /><br />
      18. <span><label for="kundennummer">Kundennummer:</label></span>
      19. <input id="kundennummer" type="text" name="Kundennummer" /><br />
      20. <h2>Zur Kalkulation benötigen wir Ihre Logodaten!</h2><br />
      21. <span><label for="logoupload">Bitte hier anhängen:</label></span>
      22. <input id="logoupload" type="file" name="Logo" />
      23. <span><label for="logouplaod">Dateiformate: jpg, tif, pdf, eps</label></span><br />
      24. <span><label for="attachdata">Angehängte Daten:</label></span>
      25. <input id="attachdata" type="text" name="AngehängteDaten" /><br /><br />
      26. <h3><u>Gewünschte Veredlungsart</u></h3><br />
      27. <input id="schneide-flock" type="checkbox" name="schneide-flock" />
      28. <span><label for="schneide-flock">Bedruckung mit <strong>Schneide-Flock</strong> (geeignet für Schriften & Vektorlogos)</label></span><br />
      29. <input id="schneide-flex" type="checkbox" name="schneide-flex" />
      30. <span><label for="schneide-flex">Bedruckung mit <strong>Schneide-Flex</strong> (geeignet für Schriften & Vektorlogos)</label></span><br />
      31. <input id="solventflex" type="checkbox" name="solventflex" />
      32. <span><label for="solventflex">Bedruckung mit <strong>Solventflex</strong> (geeignet für Schriften & Bilder/Fotos, Vektor- & Pixeldaten)</label></span><br />
      33. <input id="bestickung" type="checkbox" name="bestickung" />
      34. <span><label for="bestickung"><strong>Bestickung</strong> in unserer hauseigenen Stickerei</label></span><br />
      35. <h3><u>Mögliche Veredelungspositionen:</u></h3>
      36. <input id="brustlogo" type="checkbox" name="brustlogo" />
      37. <span><label for="brustlogo"><strong>Brustlogo</strong></label></span>
      38. <input id="brustlogo-links" type="checkbox" name="brustlogo-links" />
      39. <span><label for="brustlogo-links">links</label></span>
      40. <input id="brustlogo-rechts" type="checkbox" name="brustlogo-rechts" />
      41. <span><label for="brustlogo-rechts">rechts</label></span><br />
      42. <input id="kragenlogo" type="checkbox" name="kragenlogo" />
      43. <span><label for="kragenlogo"><strong>Kragenlogo</strong></label></span>
      44. <input id="kragenlogo-links" type="checkbox" name="kragenlogo-links" />
      45. <span><label for="kragenlogo-links">links</label></span>
      46. <input id="kragenlogo-rechts" type="checkbox" name="kragenlogo-rechts" />
      47. <span><label for="kragenlogo-rechts">rechts</label></span><br />
      48. <input id="rückenlogo" type="checkbox" name="rückenlogo" />
      49. <span><label for="rückenlogo"><strong>Rückenlogo</strong></label></span><br />
      50. <span><label for="rückenlogo-position"><strong>folgende Position anbieten</strong></label></span>
      51. <input id="rückenlogo-position" type="text" name="rückenlogo-position" /><br /><br />
      52. <span><label for="ihre-frage"><strong>Ihre Fragen:</strong></label></span><br />
      53. <textarea id="ihre-frage" style="resize:none;"></textarea><br />
      54. <h3>Ihr Kostenvoranschlag wird schnellstmöglich durch unseren Sachbearbeiter erstellt!</h3>
      55. </form>
      56. </body>
      57. </html>
      Alles anzeigen


      Dazu gibt es noch eine senden.php und einen Ordner includes mit einer functions.php. Wenn Ihr das Formular mal selber in eine HTML Datei schreibt und mit Firefox o.ä. öffnet, seht ihr das ich an einer Stelle ein Bild hochladen möchte, das ganze soll das per Email verschickt werden.
      Leider habe ich wenige Kentnisse in PHP um das komplett alleine zu schreiben..
      Kann mir jemand helfen? Bis jetzt sehen meine PHP Dateien so aus:

      senden.php:

      PHP-Quellcode

      1. <?php
      2. error_reporting(E_ALL);
      3. ini_set('display_errors', 1);
      4. include ("includes/functions.php");
      5. $koerper = erstellekoerper($_POST["freitext"]);
      6. $kopf = erstellekopf ("email@email.de" ,$koerper, "BBB", "text.txt");
      7. var_dump ($kopf);
      8. $erfolg = mail ( $_POST["email"] , $_POST["betreff"] , $koerper, $kopf);
      9. if ($erfolg === true) {
      10. echo 'Sendung erfolgreich!';
      11. } else {
      12. echo 'Sendung fehlgeschlagen.';
      13. }
      14. ?>
      Alles anzeigen


      includes/functions.php:

      PHP-Quellcode

      1. <?php
      2. function erstellekopf($absender, $text, $typ, $datei) {
      3. $anhang = fread(fopen(dirname(dirname(__FILE__)) . '/' . $datei, "r"), filesize($datei));
      4. $anhang = chunk_split(base64_encode($anhang));
      5. $boundary = md5(uniqid(time()));
      6. $kopf = "MIME-Version: 1.0\n";
      7. $kopf .= "From: Sign-Line <" . $absender . ">" . "\n";
      8. $kopf .= "Content-Type: multipart/mixed; boundary=" . $boundary . "\n\n";
      9. $kopf .= "--" . $boundary . "\n";
      10. $kopf .= "Content-Type: text/html; charset=ISO-8859-1 \n";
      11. $kopf .= "Content-Transfer-Encoding: 8bit\n\n";
      12. $kopf .= $text . "\n";
      13. $kopf .= "--" . $boundary . "\n";
      14. $kopf .= 'Content-Type: text/plain; name=' . $datei . "\n";
      15. $kopf .= "Content-Transfer-Encoding: base64\n";
      16. $kopf .= 'Content-Disposition: attachment; filename=' . $datei . "\n\n";
      17. $kopf .= $anhang . "\n";
      18. $kopf .= "--" . $boundary . "--\n";
      19. return $kopf;
      20. }
      21. function erstellekoerper($inhalt) {
      22. $mailtext = '<html>
      23. <head>
      24. <title>HTML-E-Mail mit PHP erstellen</title>
      25. </head>
      26. <body>
      27. <div style="width:600px;background-color:red;height:100px;">Slogan</div>
      28. <div style="width:600px;background-color:white;">' . $inhalt . '</div>
      29. <div style="width:600px;background-color:red;height;100px;">Kontaktdaten</div>
      30. </body>
      31. </html>
      32. ';
      33. return $mailtext;
      34. }
      35. ?>
      Alles anzeigen


      Danke im Vorraus,

      sn0w
    • Werbung zur Unterstützung des Forums ( Bitte AddBlocker deaktivieren )

    • Konnte das Problem heute doch noch lösen.

      HTML-Quellcode

      1. <!DOCTYPE html>
      2. <html>
      3. <head>
      4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      5. <title>Sign-Line Formular</title>
      6. <style>
      7. * {padding:0;margin:0;}
      8. body {font-family:Arial;font-size:12px;width:700px;margin:0 auto;}
      9. form {margin:12px 0;}
      10. input, label {display:inline-block;}
      11. label {cursor:pointer;}
      12. h1, h2, h3, h4, h5, h6 {color:#e3001b;margin:9px 0;}
      13. h2 {font-size:31px;}
      14. .header, .footer {background:#e3001b;}
      15. .header {height:100px;}
      16. .footer {height:20px;}
      17. </style>
      18. </head>
      19. <body>
      20. <div class="header">
      21. </div>
      22. <form enctype="multipart/form-data" action="senden.php" method="POST">
      23. <div class="block">
      24. <span>Hier können Sie Ihre <strong>Fragen & Veredelungswünsche</strong></span><br />
      25. <span><label for="artikelname">zum folgenden Artikel stellen:</label></span>
      26. <input id="artikelname" type="text" name="Artikelname" /><br />
      27. <span><label for="kundennummer">Kundennummer:</label></span>
      28. <input id="kundennummer" type="text" name="Kundennummer" /><br />
      29. </div>
      30. <div class="block">
      31. <h2>Zur Kalkulation benötigen wir Ihre Logodaten!</h2><br />
      32. <span><label for="logoupload">Bitte hier anhängen:</label></span>
      33. <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
      34. <input id="logoupload" type="file" name="Logo" />
      35. <span><label for="logouplaod">Dateiformate: jpg, tif, pdf, eps</label></span><br />
      36. <span><label for="attachdata">Angehängte Daten:</label></span>
      37. <input id="attachdata" type="text" name="AngehängteDaten" /><br /><br />
      38. </div>
      39. <div class="block">
      40. <h3><u>Gewünschte Veredlungsart</u></h3><br />
      41. <input id="schneide-flock" type="checkbox" name="Schneide-flock" />
      42. <span><label for="schneide-flock">Bedruckung mit <strong>Schneide-Flock</strong> (geeignet für Schriften & Vektorlogos)</label></span><br />
      43. <input id="schneide-flex" type="checkbox" name="Schneide-flex" />
      44. <span><label for="schneide-flex">Bedruckung mit <strong>Schneide-Flex</strong> (geeignet für Schriften & Vektorlogos)</label></span><br />
      45. <input id="solventflex" type="checkbox" name="Solventflex" />
      46. <span><label for="solventflex">Bedruckung mit <strong>Solventflex</strong> (geeignet für Schriften & Bilder/Fotos, Vektor- & Pixeldaten)</label></span><br />
      47. <input id="bestickung" type="checkbox" name="Bestickung" />
      48. <span><label for="bestickung"><strong>Bestickung</strong> in unserer hauseigenen Stickerei</label></span><br />
      49. </div>
      50. <div class="block">
      51. <h3><u>Mögliche Veredelungspositionen:</u></h3>
      52. <input id="brustlogo" type="checkbox" name="Brustlogo" />
      53. <span><label for="brustlogo"><strong>Brustlogo</strong></label></span>
      54. <input id="brustlogo-links" type="checkbox" name="Brustlogo-links" />
      55. <span><label for="brustlogo-links">links</label></span>
      56. <input id="brustlogo-rechts" type="checkbox" name="Brustlogo-rechts" />
      57. <span><label for="brustlogo-rechts">rechts</label></span><br />
      58. <input id="kragenlogo" type="checkbox" name="Kragenlogo" />
      59. <span><label for="kragenlogo"><strong>Kragenlogo</strong></label></span>
      60. <input id="kragenlogo-links" type="checkbox" name="Kragenlogo-links" />
      61. <span><label for="kragenlogo-links">links</label></span>
      62. <input id="kragenlogo-rechts" type="checkbox" name="Kragenlogo-rechts" />
      63. <span><label for="kragenlogo-rechts">rechts</label></span><br />
      64. <input id="rückenlogo" type="checkbox" name="Rückenlogo" />
      65. <span><label for="rückenlogo"><strong>Rückenlogo</strong></label></span><br />
      66. <span><label for="rückenlogo-position"><strong>folgende Position anbieten</strong></label></span>
      67. <input id="rückenlogo-position" type="text" name="Rückenlogo-position" /><br /><br />
      68. </div>
      69. <span><label for="ihre-frage"><strong>Ihre Fragen:</strong></label></span><br />
      70. <textarea id="ihre-frage" style="resize:none;" name="Frage"></textarea><br />
      71. <h3>Ihr Kostenvoranschlag wird schnellstmöglich durch unseren Sachbearbeiter erstellt!</h3>
      72. <input type="submit" name="senden" value="Senden!" />
      73. </form>
      74. <div class="footer">
      75. </div>
      76. </body>
      77. </html>
      Alles anzeigen


      Dann hier die senden.php:

      PHP-Quellcode

      1. <?php
      2. error_reporting(E_ALL);
      3. ini_set('display_errors', 1);
      4. include ("includes/konstanten.php");
      5. include ("includes/functions.php");
      6. $zielname = null;
      7. if(isset($_FILES["Logo"]["tmp_name"]) && !empty($_FILES["Logo"]["tmp_name"])){
      8. $zufall = rand(0, 999999999);
      9. $zielname = $zufall . $_FILES["Logo"]["name"];
      10. rename($_FILES["Logo"]["tmp_name"],dirname(__FILE__) . '/tmp/' . $zielname);
      11. }
      12. ?>
      13. <!DOCTYPE HTML>
      14. <html>
      15. <head>
      16. <meta http-equiv="content-type" content="text/html; charset=utf-8">
      17. <meta name="generator" content="PSPad editor, www.pspad.com">
      18. <title></title>
      19. </head>
      20. <body>
      21. <?php
      22. $clean = cleanInput($_POST,$zugelassene);
      23. $plain = getPlain($clean);
      24. $html = getHtml($clean);
      25. $erfolg = send_mail_with_attachment($plain, $html, $zielname);
      26. if ($erfolg === true) {
      27. if($zielname !== null){
      28. @unlink(dirname(__FILE__) . '/tmp/' . $zielname);
      29. }
      30. echo 'Sendung erfolgreich!';
      31. } else {
      32. echo 'Sendung fehlgeschlagen!';
      33. }
      34. ?>
      35. </body>
      36. </html>
      Alles anzeigen


      Hier ist die includes/functions.php:

      PHP-Quellcode

      1. <?php
      2. function send_mail_with_attachment($plain, $html, $attachmentname = null) {
      3. if($attachmentname !== null) {
      4. $attachment = fread(fopen(dirname(dirname(__FILE__)) . '/tmp/' . $attachmentname, "r"), filesize(dirname(dirname(__FILE__)) . '/tmp/' . $attachmentname));
      5. $attachment = chunk_split(base64_encode($attachment));
      6. }
      7. $random_hash = md5(date('r', time()));
      8. $mailheader = "MIME-Version: 1.0\n";
      9. $mailheader .= "From: " . SIGNLINE_FROM_NAME_ADRESSE . " <" . SIGNLINE_ABSENDER_ADRESSE . ">\n";
      10. $mailheader .= "Content-Type: multipart/mixed; boundary=\"" . $random_hash . "\"\n";
      11. $mailbody = "This is a MIME encoded message.";
      12. $mailbody .= "\n\n--" . $random_hash . "\n";
      13. $mailbody .= "Content-type: text/html;charset=utf-8\n\n";
      14. $mailbody .= $html;
      15. $mailbody .= "\n\n--" . $random_hash . "\n";
      16. $mailbody .= "Content-type: text/plain;charset=utf-8\n\n";
      17. $mailbody .= $plain;
      18. if($attachmentname !== null) {
      19. $mailbody .= "\n\n--" . $random_hash;
      20. $mailbody .= "\nContent-Type: text/plain; name=\"" . $attachmentname . "\"";
      21. $mailbody .= "\nContent-Transfer-Encoding: base64";
      22. $mailbody .= "\nContent-Disposition: attachment";
      23. $mailbody .= "\n\n" . $attachment;
      24. }
      25. $mailbody .= "\n--" . $random_hash . "--";
      26. if(mail(SIGNLINE_EMPFAENGER_ADRESSE,SIGNLINE_MAIL_BETREFF,$mailbody,$mailheader,'-f ' . SIGNLINE_ABSENDER_ADRESSE)){
      27. return true;
      28. } else {
      29. return false;
      30. }
      31. }
      32. function getHtml($datas = array()){
      33. $return = '<html><head><title></title></head><body>';
      34. $return .= '<div>';
      35. foreach($datas as $key => $value){
      36. $return .= '<div style="float:left;width:50%">' . $key . '</div><div style="float:right;width:50%">' . $value . '</div>';
      37. $return .= '<hr style="clear:both" />';
      38. }
      39. $return .= '</div>';
      40. $return .= '</body></html>';
      41. return $return;
      42. }
      43. function getPlain($datas = array()){
      44. $return = '';
      45. foreach($datas as $key => $value){
      46. $return .= $key . ': ' . $value . "\n";
      47. }
      48. return $return;
      49. }
      50. function cleanInput($post,$zugelassene){
      51. $return = array();
      52. foreach($zugelassene as $value){
      53. if(isset($post[$value]) && !empty($post[$value])){
      54. $uebergabe = $post[$value];
      55. $uebergabe = htmlentities($uebergabe);
      56. $uebergabe = str_replace("(", '(', $uebergabe);
      57. $uebergabe = str_replace(")", ')', $uebergabe);
      58. $uebergabe = strip_tags($uebergabe);
      59. $return[$value] = $uebergabe;
      60. }
      61. }
      62. return $return;
      63. }
      64. ?>
      Alles anzeigen


      Und es gibt eine neue Datei im includes Ordner die heißt konstanten.php:

      PHP-Quellcode

      1. <?php
      2. define('SIGNLINE_EMPFAENGER_ADRESSE', 'luca.koch@net-jet.de');
      3. define('SIGNLINE_ABSENDER_ADRESSE', 'info@jimmo-tool.de');
      4. define('SIGNLINE_FROM_NAME_ADRESSE', 'Sign-Line System');
      5. define('SIGNLINE_MAIL_BETREFF', 'Sign-Line Kalkulationsmail eingetroffen.');
      6. $zugelassene = array(
      7. "Artikelname",
      8. "Kundennummer",
      9. "Logo",
      10. "AngehängteDaten",
      11. "Schneide-flock",
      12. "Schneide-flex",
      13. "Solventflex",
      14. "Bestickung",
      15. "Brustlogo",
      16. "Brustlogo-links",
      17. "Brustlogo-rechts",
      18. "Kragenlogo",
      19. "Kragenlogo-links",
      20. "Kragenlogo-rechts",
      21. "Rückenlogo",
      22. "Rückenlogo-position",
      23. "Frage"
      24. );
      25. ?>
      Alles anzeigen


      Vielleicht hilft das ja einem. Ich lass es einfach mal hier. :)