Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

PHP Send pdf file as attachment in email

PHP Send pdf file as attachment in email

I am trying to send a pdf file as attchment in my email.

 Using following code.

send pdf file as attachment in email php
Send pdf file as attachment in email php

PHP send pdf file extension mpdf download and include this mpdf.php file in your code. Send pdf file as attachment in email php

    $mpdf = new mPDF('c', 'A4-L', '', '', 0, 0, 0, 0, 0, 0);
    $mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
    $filename = "Jims_tradenet_form.txt";

content.='<html lang="en-AU"><head><link rel="stylesheet" href=""><link rel="stylesheet" href=""><link rel="stylesheet" href=""><script src=""></script>
   <style type="text/css">          
            .form-group { padding-bottom: 5px; }
            label { font-size:12px; }          
        <div class="container">
            <section class="header" style="border-bottom:1px solid #000;">
                <div class="row">
                    <div class="col-md-3" style="min-height: 70px; max-height: 150px;">
                        <img src="" class="pull-left" style="max-width: 300px; opacity: .7;" />
                    <div class="col-md-6 text-center">
                        <h3 class="center" style="opacity:0.7; font-family: helvetica; font-weight: bold;">MY FIRST PDF FILE SEND MAIL</h3>
                    <div class="col-md-3 center">
                        <img src="" class="pull-right" style="max-width: 300px; opacity: .7; max-height: 60px;" />
 $file = fopen($filename, "w");
    fwrite($file, $content);
    $m = time();
    $n = $m . '.pdf';
    $m = 'files/' . $m . '.pdf';
    $mpdf->Output($m, 'F');
    $_SESSION['file'] = $m;


    $emailBody .= '';

    $fileatt = $m; // Path to the file                
    $fileatt_type = "application/pdf"; // File Type
    $fileatt_name = $n; // Filename that will be used for the file as the attachment

    $email_from = ""; // Who the email is from
    $email_subject = "Attached File"; // The Subject of the email
    $email_message = $emailBody;

    $email_to = ''; // Who the email is to

    $headers = "From: " . $email_from;

    $file = fopen($fileatt, 'rb');
    $data = fread($file, filesize($fileatt));

    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

    $headers.= "\nMIME-Version: 1.0\n" .
            "Content-Type: multipart/mixed;\n" .
            " boundary=\"{$mime_boundary}\"";

    $email_message.= "This is a multi-part message in MIME format.\n\n" .
            "--{$mime_boundary}\n" .
            "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
            "Content-Transfer-Encoding: 7bit\n\n" .
            $email_message.= "\n\n";

    $data = chunk_split(base64_encode($data));

    $email_message.= "--{$mime_boundary}\n" .
            "Content-Type: {$fileatt_type};\n" .
            " name=\"{$fileatt_name}\"\n" .
            //"Content-Disposition: attachment;\n" .
            //" filename=\"{$fileatt_name}\"\n" .
            "Content-Transfer-Encoding: base64\n\n" .
            $data.= "\n\n" .
    mail($email_to, $email_subject, $email_message, $headers);
    $msg = "Successfully Inserted";

Tips to design good website

Hi viewers,
Tips to design website
Tips to design website


Tips to design good website

While large beautiful pictures may look nice, it actually could harm your websites success, especially considering with 2G.
When starting out web design the first and foremost tasks is not to configure a new Photoshop project to the specifications of the new page. On the contrary tasks such as planning and creating the wireframe, making sure you list all the issues related the website loading speed and efforts in the direction of picking the right design format for the website are more important.
The website design can always be optimised for speed and it is also possible to make other minor tweaks at a later stage. However, this is not the best practice for designing a website.
Thus when set out to design fast and effective website here is the main factors to consider and steps to take:
Website Loading Speed
The website loading time is of great importance. This is one factor that almost everyone is aware off in this highly mobile world. Just about every other person is using their mobile device to access the internet.
Thus the important factors to keep in mind when developing a website are that your website is going to be viewed on devices of multiplatform and multiple sizes. Besides which each device will have varying network connection speeds as well.
Optimized images
Using massive images on the website is a rookie mistake that almost all of us make. Many of us do allow the use of massive images on the website since the Internet speed is gradually on the rise.
On an average one expects just about everyone to have fast broadband connection or connected to a 3G, 4G or above mobile network, which deliver high speed internet.
The fact of the matter is that massive images are still not advisable. The big images will still slow down the website and affect the overall performance of the website. Besides which it is also necessary to make sure your images are responsive too, so that it appears good on the mobile browser.
Fancy Code
Placing fancy code is all very well. Just about everyone prefers a fancy website to a drab and dull one. However there many alternatives to slow loading graphics and animations when it comes to creating more appealing websites.
One of the easiest and quickest approach is to use plain HTML5, CSS3 and even make use of JavaScript to develop stunning websites that can even have an edge over their competitor.
Other factors
There are several other factors that can help you develop faster and more efficient websites. This mainly on the type of website you are developing. For a PHP website, it is necessary to optimise the database queries to make sure it is efficient.
For a WordPress website it is possible to follow certain design techniques that make sure your WordPress website is optimised. A similar concept applies to all other types of websites too.

PHP image rotate and move local disk

Normal core php input file upload image rotate same degree static or dynamicly image rotate and showing the image original image and rotate image separate  image local disk folder move.


<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" name="rotate" value="rotate" />
    echo $image;
    $imagename = "image/".$image;
    $source= imagecreatefromjpeg($imagename);
<td height="500px" width="500px" align="center">
<img src="image/<?php echo $image;?>" width="300px" height="300px" />
<td headers="500px" width="500px" align="center"><img src="rotated/<?php echo $image?>" width="300px" height="300px" /></td></tr>

Output Screen

How to Input string get Diamond shape Php

Normal Core PHP simple Input text box get string is viewed diamond shape.


<form action="" method="post">
Enter the String : <input type="text" name="text" id="text" value="" />
<input type="submit" name="submit" id="submit" value="submit" />
echo "<center>";
echo $string[$j];
echo "<br>";
echo $string[$j];
echo "<br>";
echo "</center>";


Output Screen: