Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: please check php form code

  1. #11
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    902
    Thanks
    113
    Thanked 2 Times in 2 Posts

    Default

    Thanks for your remarks, DyDr.
    The gmail is not the mail adres I'm using; just placed it here to fill in a mail adress other than mine.

    This is the code so far, adjusted from all comments. Just the log.txt isn't working well (error 500).
    How does it look to you?

    Code:
    <?php
    
    function _log($log_file,$ip,$email,$message) 
    { 
        $str = date('Y-m-d H:i:s') . " IP:$ip, EM:$email, $message\r\n"; 
        file_put_contents($log_file,$str,FILE_APPEND); 
    } 
    
    $log_file = 'http://www.domain.com/logs/log.txt';
    
    $ip = $_SERVER['REMOTE_ADDR'];  
    
    $website_naam = 'NAME WEBSITE';
    $eigen_emailadres = 'bruno@domain.com';
    $error_emailadres = 'bruno@domain.com';
    $naam_verzender = 'Afzender';
    $email_verzender = 'emailadres_van_verzender@zijn_domein.nl';
    $bcc_emailadres = 'bruno@domain.com';
    $html = true;
    
    $to = "bruno@domain.com";
    $subject= "inschrijving";
    $message = "
    Faciliteit: $_POST['faciliteit'];
    Naam bedrijf: $_POST['cmname'];
    Adres: $_POST['add']; $_POST['zip']; $_POST['city'];
    
    Beschrijving:
    $_POST['beschrijving'];
    
    Video:
    $_POST['socialURL'];
    
    Kernwoorden: 
    $_POST['keywords1'];
    $_POST['keywords2'];
    $_POST['keywords3'];
    $_POST['keywords4'];
    $_POST['keywords5'];
    $_POST['keywords6'];
    
    Prijslijst:
    $_POST['prijslijst'];
    
    
    Openklikbare tekst:
    $_POST['klikbaar'];
    
    
    Contactpersoon: $_POST['name'];
    Telefoon: $_POST['phone'];
    Email: $_POST['email'];
    Website: $_POST['website'];
    
    Openingsuren: 
    $_POST['openingsuren'];
    
    Facebook: $_POST['socialFB'];
    Instagram: $_POST['socialIN'];
    Twitter: $_POST['socialTW'];
    Google Plus: $_POST['socialGP'];
    
    Verdere opmerkingen:
    $_POST['opmerking'];
    ";
      $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
             $message = "This is a multi-part message in MIME format.\n\n" .
                "--{$mime_boundary}\r\n" .
                "Content-Type: text/plain; charset=\"utf-8\"\r\n" .
                "Content-Transfer-Encoding: 7bit\n\n" .
             $message . "\n\n";
             foreach($_FILES as $userfile)
             {
                $tmp_name = $userfile['tmp_name'];
                $type = $userfile['type'];
                $name = $userfile['name'];
                $size = $userfile['size'];
                if (file_exists($tmp_name))
                {
                   if(is_uploaded_file($tmp_name))
                   {
                      $file = fopen($tmp_name,'rb');
                      $data = fread($file,filesize($tmp_name));
                      fclose($file);
                      $data = chunk_split(base64_encode($data));
                   }
                   $message .= "--{$mime_boundary}\r\n" .
                      "Content-Type: {$type};\r\n" .
                      " name=\"{$name}\"\r\n" .
                      "Content-Disposition: attachment;\r\n" .
                      " filename=\"{$fileatt_name}\"\r\n" .
                      "Content-Transfer-Encoding: base64\n\n" .
                   $data . "\n\n";
                }
             }
             $message.="--{$mime_boundary}--\r\n";
    
            $headers    = 'From: ' . $website_naam . ' <' . $eigen_emailadres . '>' . "\r\n";
            $headers    .= 'Reply-To: ' . $naam_verzender . ' <' . $email_verzender . '>' . "\r\n";
            $headers    .= 'Return-Path: Mail-Error <' . $error_emailadres . '>' . "\r\n";
            $headers    .= ($bcc_emailadres != '') ? 'Bcc: ' . $bcc_emailadres . "\r\n" : '';
            $headers    .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
            $headers    .= 'X-Priority: Normal' . "\r\n";
            $headers    .= ($html) ? 'MIME-Version: 1.0' . "\r\n" : '';
            $headers    .= ($html) ? 'Content-type: text/html; charset=utf-8' . "\r\n" : '';
            $headers    .= ($html) ? "Content-Type: multipart/mixed;\r\n" .
            $headers    .= ($html) ? "boundary=\"{$mime_boundary}\"";
    
            if(mail($to, $subject, $message, $headers)) 
            { 
                echo "Dankje om je gegevens door te zenden.<br>We nemen die door en contacteren je zo snel mogelijk."; 
                _log($log_file,$ip,$email,'Mail call successful.'); 
    
            } else { 
                echo "Error in mail.<br>Probeer opnieuw door hieronder te klikken."; 
                $last_error = error_get_last(); 
                _log($log_file,$ip,$email,"Mail call failed - {$last_error['message']}"); 
    
            }
    ?>

  2. #12
    Join Date
    Dec 2017
    Location
    Chandigarh, India
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Too Much Copied Variables

    It is not working as too much copied variables

  3. #13
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    902
    Thanks
    113
    Thanked 2 Times in 2 Posts

    Default

    Thanks, Surya.
    What needs to be removed then?

Similar Threads

  1. Could you check my code please
    By theremotedr in forum CSS
    Replies: 12
    Last Post: 01-21-2016, 11:05 AM
  2. code check please
    By bwc in forum PHP
    Replies: 8
    Last Post: 06-17-2009, 07:39 AM
  3. Resolved Hello im new to CSS can you check this code?
    By PSG1JOHN in forum CSS
    Replies: 5
    Last Post: 03-08-2009, 03:07 PM
  4. Please Check my code (PHP)
    By laserdude in forum PHP
    Replies: 2
    Last Post: 04-02-2007, 06:15 PM
  5. can anyone check code
    By newj in forum ASP
    Replies: 0
    Last Post: 02-18-2007, 04:13 PM

Bookmarks

Posting Permissions

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