Ankündigung

Einklappen
Keine Ankündigung bisher.

Newsletter-Option einbauen, Haken machen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Newsletter-Option einbauen, Haken machen

    Hallo ich habe für eine Webseite ein Kontakt-formular-Script gefunden:
    PHP-Code:
    <?php
    // Your e-mail adress:
    $mailto "[email protected]";

    # Maximum size of attachment in bytes:
    $max_attach_size 500000;

    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Formmailer</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    <!--
    body                { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000; background: #ffff3; margin: 20px; padding: 0px; border: 0px; }
    .caution            { color: red; font-weight: bold; }
    -->
    </style>
    </head>
    <body><?php
    /*if (empty($_POST['form_submitted']))
     {
      ?><p>Please fill out the form:</p><?php
     }
    */
     
    if (isset($_POST["form_submitted"]))
     {
      
    $name trim(preg_replace("/\r/"""$_POST['name']));
      
    $name preg_replace("/\n/"""$name);
      
    $name stripslashes($name);
      
    $email trim(preg_replace("/\r/"""$_POST['email']));
      
    $email preg_replace("/\n/"""$email);
      
    $subject trim(stripslashes($_POST['subject']));
      
    $text trim(stripslashes($_POST['text']));

      unset(
    $errors);
      if(
    $email == ""$errors[] = "no e-mail address entered";
      elseif(
    $email != "" and !preg_match("/^[^@][email protected]+\.\D{2,5}$/"$email)) $errors[] = "e-mail address seems to be invalid";
      if(
    $text == ""$errors[] = "no message entered";
      if(
    $_FILES['probe']['size'] > $max_attach_size$errors[] = "attachment too large (".number_format($_FILES['probe']['size']/1000,0,",","")." KB) - maximum size: ".number_format($max_attach_size/1000,0,",","")." KB";

      if (empty(
    $errors))
       {
        
    #if ($name != "") $mail_name=$name; else $mail_name="Unknown";
        
    if ($subject != ""$mail_subject $subject; else $mail_subject "No subject";
        
    #if ($email != "") $mail_email = $email; else $mail_email = "[email protected]";
        
    $ip $_SERVER["REMOTE_ADDR"];

        
    // if attachment, MIME-Mail:
        
    if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "")
         {
          
    // read and encode file:
          
    $datei_content fread(fopen($_FILES['probe']['tmp_name'],"r"),filesize($_FILES['probe']['tmp_name']));
          
    $datei_content chunk_split(base64_encode($datei_content),76,"\n");
          
    // Boundary:
          
    $boundary md5(uniqid(rand()));
          
    // Mail-Header:
          
    $mail_header "From: ".$name." <".$email.">\n";
          
    $mail_header .= "X-Sender-IP: ".$ip."\n";
          
    $mail_header .= "MIME-Version: 1.0\n";
          
    $mail_header .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
          
    $mail_header .= "This is a multi-part message in MIME format.\n";
          
    // Mail-Text:
          
    $mail_header .= "--".$boundary;
          
    $mail_header .= "\nContent-Type: text/plain";
          
    $mail_header .= "\nContent-Transfer-Encoding: 8bit";
          
    $mail_header .= "\n\n".$text;
          
    // Attachment:
          
    $mail_header .= "\n--".$boundary;
          
    $mail_header .= "\nContent-Type: ".$_FILES['probe']['type']."; name=\"".$_FILES['probe']['name']."\"";
          
    $mail_header .= "\nContent-Transfer-Encoding: base64";
          
    $mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['probe']['name']."\"";
          
    $mail_header .= "\n\n".$datei_content;
          
    // End:
          
    $mail_header .= "\n--".$boundary."--";
          
    // Sende E-Mail und gebe Fehler bzw. Bestaetigung aus
          
    if (@mail($mailto,$mail_subject,"",$mail_header)) $sent true; else $errors[] = "no connection to the mailserver - please try again later";
         }
        
    // no attachment, normal E-mail:
        
    else
         {
          
    $mail_header "From: ".$name." <".$email.">\n";
          
    $mail_header .= "X-Sender-IP: $ip\n";
          
    $mail_header .= "Content-Type: text/plain";
          if (@
    mail($mailto,$mail_subject,$text,$mail_header)) $sent true; else $errors[] = "no connection to the mailserver - please try again later";
         }

        
    // copy to sender:
        
    if (isset($sent))
         {
          
    $copy_subject strip_tags($mail_subject);
          
    $copy_subject str_replace('http://','',$copy_subject);
          
    $copy_subject str_replace('www.','www. ',$copy_subject);
          
    $copy_text strip_tags($text);
          
    $copy_text str_replace('http://','',$copy_text);
          
    $copy_text str_replace('www.','www. ',$copy_text);
          if (isset(
    $_FILES['probe']['name']) && trim($_FILES['probe']['name']) != ""$copy_text "Subject: ".$copy_subject."\n\n".$copy_text."\n\nAttachment: ".$_FILES['probe']['name']; else $copy_mail_text "Subject: ".$mail_subject."\n\n".$copy_text;
          
    $header"From: ".$mailto."\n";
          
    $header .= "X-Sender-IP: ".$ip."\n";
          
    $header .= "Content-Type: text/plain";
          @
    mail($email"Copy of sent e-mail"$copy_text$header);
         }
       }
     }

    if (empty(
    $sent))
     {
      if(isset(
    $errors))
       {
        
    ?><p class="caution">Error:</p><ul><?php foreach($errors as $f) { ?><li><?php echo $f?></li><?php ?></ul><br /><?php
       
    }

      
    ?><form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data"><div>
      <p><b>Name:</b><br /><input type="text" name="name" value="<?php if (isset($name)) echo htmlentities(stripslashes($name)); else echo ""?>" size="35" /></p>
      <p><b>E-mail:</b><br /><input type="text" name="email" value="<?php if (isset($email)) echo htmlentities(stripslashes($email)); else echo ""?>" size="35" /></p>
      <p><b>Subject:</b><br /><input type="text" name="subject" value="<?php if (isset($subject)) echo htmlentities(stripslashes($subject)); else echo ""?>" size="35" /></p>
      <p><b>Message:</b><br /><textarea name="text" cols="55" rows="12"><?php if (isset($text)) echo htmlentities(stripslashes($text)); else echo ""?></textarea></p>
      <b>Attachment:</b><br /><input type="file" name="probe" value="<?php if (isset($_POST['probe'])) echo htmlentities(stripslashes($_POST['probe'])); else echo ""?>" size="20"/></p>
      <br /><br />
      <p><input type="submit" name="form_submitted" value="OK - Submit" /></p>
      </div></form><?php
     
    }
    else
     {
      if (empty(
    $email)) { ?><p><b>Thank you!</b><br />The message has been sent successfully but you didn't specify your e-mail address so I can't reply.</p><?php }
      else { 
    ?><p><b>Thank you!</b><br />The message has been sent successfully.</p><?php }
     }

    // If you want to remove the Link please donate some Euros:
    // http://www.mylittlehomepage.net/donation.html

    ?><p style="margin-top: 25px; font-size: 11px;">Script by <a class="sln" href="http://www.mylittlehomepage.net/">Alex</a></p>
    </body>
    </html>
    Dieses Script habe ich in eine andere Seite Namens "kontakt.html" included.

    Jetzt hätte ich gerne, dass man zusätzlich noch einen Haken machen kann, ob man einen Newsletter haben will oder nicht.
    Soweit ich weiß, baue ich das so ein:

    <input checked name="Newsletter" type="checkbox" value="ja">

    Nur habe ich keinen blassen Schimmer, was ich da jetzt noch in dem PHP-Script ändern muss, damit in der versendeten Mail drin steht, Newsletter wurde aboniert oder eben nicht.

    Könnt ihr mir bitte helfen?
    http://www.erlebniswelt-museum.de/index.html

  • #3
    AW: Newsletter-Option einbauen, Haken machen

    ja und wie und wo muss ich das einbauen? Ich kenn mich mit PHP überhaupt nicht aus
    http://www.erlebniswelt-museum.de/index.html

    Kommentar


    • #4
      AW: Newsletter-Option einbauen, Haken machen

      Zitat von Jaws Beitrag anzeigen
      ja und wie und wo muss ich das einbauen? Ich kenn mich mit PHP überhaupt nicht aus
      hier wird dir keiner was vorkauen. lies dich rein, oder lass es sein. (hey das reimt sich!)
      AC/DC Fanpage www.ifyouwantblood.de
      Nein zur Zensur im Internet und anderswo - Anonymous

      Kommentar


      • #5
        AW: Newsletter-Option einbauen, Haken machen

        also ich hab jetzt schon X-mal rumprobiert, hier was eingefügt, da was gelöscht, aber alles funktioniert nicht. Ich habe keine Ahnung.
        http://www.erlebniswelt-museum.de/index.html

        Kommentar


        • #6
          AW: Newsletter-Option einbauen, Haken machen

          Schreibe hinter

          Code:
          $text = trim(stripslashes($_POST['text']));


          Code:
          if($_POST['Newsletter'] == 'ja')
          {
          $text .= ' Newsletter wurde aboniert';
          }
          Meine neue private Homepage ist fertig. Es wird um Meinungen, Anregungen, Kritik und Gästebucheinträge gebeten: http://markus.ug-team.de

          Kommentar

          homepage-forum.de - Hilfe für Webmaster! Statistiken

          Einklappen

          Themen: 57.205   Beiträge: 432.331   Mitglieder: 29.597   Aktive Mitglieder: 46
          Willkommen an unser neuestes Mitglied, Drausi.

          Online-Benutzer

          Einklappen

          746 Benutzer sind jetzt online. Registrierte Benutzer: 3, Gäste: 743.

          Mit 4.707 Benutzern waren am 12.01.2023 um 03:07 die meisten Benutzer gleichzeitig online.

          Die neuesten Themen

          Einklappen

          Die neuesten Beiträge

          Einklappen

          Lädt...
          X