1. Përshëndetje dhe mirësevini në forumin e Itshqip.com
    Nëse akoma nuk jeni pjesë e IT komunitetit më të madhë Shqiptarë nga fusha e Teknologjisë Informative, ju ftojmë që të bëheni pjesë e këtij komuniteti që tani duke u regjistruar këtu - procedura është shumë e thjeshtë dhe e lehtë. Gjithashtu ju mund të regjistroheni edhe përmes rrjetit social Facebook, Twitter, Google+.

Pyetje Problem kontakt forma nuk po i dergon mesazhet

Tema tek 'PHP // ASP // Python' e hapur nga IamEnis, 14 Maj 2019.

  1. IamEnis

    IamEnis Anëtar

    Postimet:
    11
    Pëlqimet:
    1
    Pikë nga trofetë:
    13
    Pershendetje ITshqip, kam nje problem me webfaqen gjegjsisht tek kontakt forma e kam bo lidhjen me databazen edhe e kam kriju databazen ne host por nuk po e dergon mesazhin dmth spo komunikon me serverin:
    db.php
    Code:
    <?php
    ini_set("display_errors",1);
    $servername = "localhost";
    $dbname = "###";
    
    $username = "###";
    $password = "###";
    
    // Create connection
    $conn = new mysqli($servername, $username, $password,$dbname);
    
    // Check connection
    if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }
    
    function mime_type($file) {
    
    $mime_type = array(
    'txt' => 'text/plain',
    'htm' => 'text/html',
    'html' => 'text/html',
    'php' => 'text/html',
    'css' => 'text/css',
    'js' => 'application/javascript',
    'json' => 'application/json',
    'xml' => 'application/xml',
    'swf' => 'application/x-shockwave-flash',
    'flv' => 'video/x-flv',
    
    // images
    'png' => 'image/png',
    'jpe' => 'image/jpeg',
    'jpeg' => 'image/jpeg',
    'jpg' => 'image/jpeg',
    'gif' => 'image/gif',
    'bmp' => 'image/bmp',
    'ico' => 'image/vnd.microsoft.icon',
    'tiff' => 'image/tiff',
    'tif' => 'image/tiff',
    'svg' => 'image/svg+xml',
    'svgz' => 'image/svg+xml',
    
    // archives
    'zip' => 'application/zip',
    'rar' => 'application/x-rar-compressed',
    'exe' => 'application/x-msdownload',
    'msi' => 'application/x-msdownload',
    'cab' => 'application/vnd.ms-cab-compressed',
    
    // audio/video
    'mp3' => 'audio/mpeg',
    'qt' => 'video/quicktime',
    'mov' => 'video/quicktime',
    
    // adobe
    'pdf' => 'application/pdf',
    'psd' => 'image/vnd.adobe.photoshop',
    'ai' => 'application/postscript',
    'eps' => 'application/postscript',
    'ps' => 'application/postscript',
    
    // ms office
    'doc' => 'application/msword',
    'rtf' => 'application/rtf',
    'xls' => 'application/vnd.ms-excel',
    'ppt' => 'application/vnd.ms-powerpoint',
    
    // open office
    'odt' => 'application/vnd.oasis.opendocument.text',
    'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
    // etc...
    // truncated due to Stack Overflow's character limit in posts
    );
    
    $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
    
    
    if (isset($mime_type[$extension])) {
    return $mime_type[$extension];
    } else {
    throw new Exception("Unknown file type");
    }
    
    }
    
    ?>
    
    contact.php
    Code:
    <?php 
    ini_set("display_errors","off");
    include('db.php');
    $source_from=strip_tags($_POST["source_from"]);
    $first_name=strip_tags($_POST["first_name"]);
    $last_name=strip_tags($_POST["last_name"]);
    $email=strip_tags($_POST["email"]);
    $phone=strip_tags($_POST["phone"]);
    $message2=strip_tags($_POST["message"]);
    
    
    $ip =$_SERVER['REMOTE_ADDR'];
    $date_enq=date('Y-m-d h:i:a');
    
    $to = '###';
    
    $subject = 'Enquiry from Contact Form ';
    
    $headers = "From: " . strip_tags('###') . "\r\n";
    $headers .= "Reply-To: ". strip_tags('###') . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    
    $message = '<p><strong>New Contact Enquiry</strong></p>';
    $message .= '<p><strong>Enquiry For:</strong>'.$source_from.'</p>';
    $message .= '<p><strong>First Name:</strong>'.$first_name.'</p>';
    $message .= '<p><strong>Last Name:</strong>'.$last_name.'</p>';
    $message .= '<p><strong>Email:</strong>'.$email.'</p>';
    $message .= '<p><strong>Phone:</strong>'.$phone.'</p>';
    $message .= '<p><strong>Message:</strong>'.$message.'</p>';
    
    if(mail($to, $subject, $message, $headers))
    {
    
    $sql = "INSERTINTO `contact` (`source`, `first_name`, `last_name`, `phone`, `email`, `message`, `ip`, `enq_date`) VALUES ('".$source_from."', '".$first_name."', '".$last_name."', '".$phone."','".$email."','".$message2."','".$ip."','".$date_enq."')";
    
    if ($conn->query($sql) === TRUE) {
    $dinsmsg= "Data Inserted Successfully";
    } else {
    $dinsmsg= "Error: " . $sql . "<br>" . $conn->error;
    }
    
    
    $result=array("RESULT"=>"success","MSG"=>"Thanks for your enquiry , we will be get back to you soon.","dinsmsg"=>$dinsmsg);
    }
    else
    {
    $result=array("RESULT"=>"failed","MSG"=>"Opps... there is some issue occured while sending enquiry");
    
    }
    echo json_encode($result);
    
    
    ?> 
    
     
  2. selim canar

    selim canar Anëtar Fillestar

    Postimet:
    92
    Pëlqimet:
    13
    Pikë nga trofetë:
    8
    Code:
    https://php.net/manual/en/function.mail.php
     
    sodovina-city dhe IamEnis pëlqejnë postimin.

Shpërndaje faqen

Loading...