1. #1
    Dubbelpunt's Avatar
    Registered
    23/03/09
    Location
    Belgie
    Posts
    5,054
    iTrader
    5 (86%)
    Mentioned
    0 Post(s)

    PHP formulier laten werken

    Dit formulier zorgt ervoor dat de ontvanger altijd veranderd, dit zodat het werk evenredig zou verdeeld worden tussen de verschillende medewerkers.

    Nu is het zo dat de auto-response-mail niet altijd toekomt, dit is vooral een probleem bij de telenet en skynet adressen. Kan iemand mij helpen of eventueel een offerte sturen voor dit probleem.


    PHP Code:
    <?php ob_start();

    include_once(
    'verbinding.php');

    $result1 mysql_fetch_array (mysql_query("SELECT COUNT(*) FROM `Clicks` WHERE Aan = '0'")); // controleren hoeveel rijen er zijn met "Aan" op 0
    $lijst1 $result1[0];
    if(
    $lijst1=='0') { // als de lijst leeg is wil dit zeggen dat ze allemaal op 1 staan en mogen ze gereset worden.
    mysql_query("UPDATE `Clicks` SET `Aan`= '0' WHERE `Aan`='1'");
    // indien er ook maar 1 veld op 0 staat zal er direkt naar hier worden gesprongen

    $result mysql_fetch_array(mysql_query("SELECT ID,Email FROM `Clicks` WHERE Aan = '0' ORDER BY RAND() LIMIT 1"));
    $naarwie $result['Email'];
    $ID $result['ID'];
    echo 
    $ID;
    echo 
    $naarwie;

    mysql_query("UPDATE `Clicks` SET `Aan`= '1' WHERE ID = '$ID'");



    mysql_close($verbinding);          // Sluit de verbinding.
                                    //   We hebben hem nu niet meer nodig. 
    $IP $_SERVER['REMOTE_ADDR'];
            
    $DATE date("Y-m-d");
            
    $TIME date("H:i:s");


    $fromemail="No-Reply <ikwerkthuis.be>"// change here if you want
    $toemail=$naarwie;   // change here if you want
    $sub="Online info aanvraag";          // change here if you want
    $success_page_name="bedankt.html";
    ////// do not change in following
    if($_SERVER['REQUEST_METHOD']=="POST")
    {
    $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1']));  
    $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2']));  
    $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3']));  
    $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4']));  
    $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5']));  
    $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6']));  
    $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7'])); 


    $contentmsg=stripslashes('<br><b><font style=color:#CC3300>'$sub .'</font></b><br>
    <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Voornaam *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_1 .'</td>
    </tr>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Achternaam *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_2 .'</td>
    </tr>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>E-mail *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_3 .'</td>
    </tr>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Telefoon *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_4 .'</td>
    </tr>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Werkstatus *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_5 .'</td>
    </tr>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Leeftijd *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_6 .'</td>
    </tr>

    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Regio *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>'
    $fieldnm_7 .'</td>
    </tr>

    </table><br>
    Contactpersoon: '
    $naarwie .'<br>
    IP: '
    $IP .'<br>
    Date: '
    $DATE .'<br>
    Time: '
    $TIME .'
    '
    );

    ////
    $headers  "MIME-Version: 1.0
    "
    ;
    $headers .= "Content-type: text/html; charset=iso-8859-1
    "
    ;
                    
    $from=$fromemail;
                    
    $headers .= "From: ".$from.
    "
    ;
                    
    @
    mail($toemail,$sub,$contentmsg,$headers);
    //eerste log maken 

    $filename 'formulier.log.html';
    $somecontent $contentmsg;

    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {

        
    // In our example we're opening $filename in append mode.
        // The file pointer is at the bottom of the file hence
        // that's where $somecontent will go when we fwrite() it.
        
    if (!$handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
        }

        
    // Write $somecontent to our opened file.
        
    if (fwrite($handle$somecontent) === FALSE) {
            echo 
    "Cannot write to file ($filename)";
            exit;
        }

        echo 
    "Success, wrote ($somecontent) to file ($filename)";

        
    fclose($handle);

    } else {
        echo 
    "The file $filename is not writable";
    }


    //auto reply mail sturen.

            
    $IP $_SERVER['REMOTE_ADDR'];
            
    $DATE date("Y-m-d");
            
    $TIME date("H:i:s");
            
    $NameOfSender $fieldnm_1;
            
    $SurnameOfSender $fieldnm_2;
            
    //$emailadd = $naarwie;
    $headers2  "MIME-Version: 1.0
    "
    ;
    $headers2 .= "Content-type: text/html; charset=iso-8859-1
    "
    ;
                    
    $from=$naarwie;
                    
    $headers2 .= "From: ".$from.
    "
    ;
        

    $email $fieldnm_3// use their addy instead of yours
    $subject 'ikwerkthuis.be inloggegevens introductie film'// change subject
    $text 'Beste  '$NameOfSender .' '$SurnameOfSender .',<br>
    <br>
    Welkom bij <A HREF="ikwerkthuis.be" TABINDEX="4">ikwerkthuis.be</A>.<br>
    Hieronder vind U de logingevens voor het bekijken van de introductiefilm:<br>
    <br>
    Adres:            <A HREF="http://ikwerkthuis.be/index.php/introductie" TABINDEX="4">http://ikwerkthuis.be/index.php/introductie</A><br>
    Gebruikersnaam:   introductie<br>
    Paswoord:         film2012<br>
    '
    $contentmsg .'<br>
    <br>
    Wij nemen spoedig contact met u op.<br>
    <br>
    Met vriendelijke groeten,<br>
    Het ikwerkthuis.be team<br>
    <br>
    <br>
    <br>'
    // change text

    mail($email$subject$text,$headers2); // send another one 

    $filename 'auto.reply.log.html';
    $somecontent $text;

    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {

        
    // In our example we're opening $filename in append mode.
        // The file pointer is at the bottom of the file hence
        // that's where $somecontent will go when we fwrite() it.
        
    if (!$handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
        }

        
    // Write $somecontent to our opened file.
        
    if (fwrite($handle$somecontent) === FALSE) {
            echo 
    "Cannot write to file ($filename)";
            exit;
        }

        echo 
    "Success, wrote ($somecontent) to file ($filename)";

        
    fclose($handle);

    } else {
        echo 
    "The file $filename is not writable";
    }
    header("Location:$success_page_name");
    }
    ?>
    no votes  

  2. #2
    adrianhates's Avatar
    Registered
    23/01/06
    Posts
    2,115
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    23/23
    Ik heb geen interesse in de job maar heb wel een opmerking:
    De emails komen misschien niet aan omdat je from geen geldig emailadres is .. Probeer dat al ne keer aan te passen.

    En voor de rest:
    Sorry om het te zeggen maar die code is alles behalve mooi en efficient.
    ( trekt op niks, dat dit al werkt fwiw ..
    no votes  

  3. #3
    Curahee Q's Avatar
    Registered
    07/12/07
    Location
    Hoogstraten
    Posts
    854
    iTrader
    0
    Mentioned
    0 Post(s)
    Je kan beter iets gebruiken als SwiftMailer (Powerful component based mailing library for PHP – Swift Mailer). Die voegt al de juiste headers toe die nodig zijn om uw mail te laten aankomen.
    no votes  

  4. #4
    Dubbelpunt's Avatar
    Registered
    23/03/09
    Location
    Belgie
    Posts
    5,054
    iTrader
    5 (86%)
    Mentioned
    0 Post(s)
    Ik geef het alternatief door (niet alle vragen die ik hier stel, zijn voor mij persoonlijk).
    no votes  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in