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

 
    include("MPDF53/mpdf.php");
    $mpdf = new mPDF('c', 'A4-L', '', '', 0, 0, 0, 0, 0, 0);
    $mpdf->SetDisplayMode('fullpage');
    $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="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
   <style type="text/css">          
            .form-group { padding-bottom: 5px; }
            label { font-size:12px; }          
        </style>      
    </head>
    <body>
        <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="https://www.nbaysitsolutions.com.au/images/logo.png" class="pull-left" style="max-width: 300px; opacity: .7;" />
                    </div>
                    <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>
                    <div class="col-md-3 center">
                        <img src="https://www.jimstradenet.com/basis/images/tradex-logo.png" class="pull-right" style="max-width: 300px; opacity: .7; max-height: 60px;" />
                    </div>
                </div>
            </section>'
 $file = fopen($filename, "w");
    fwrite($file, $content);
    $mpdf->WriteHTML(file_get_contents($filename));
    $m = time();
    $n = $m . '.pdf';
    $m = 'files/' . $m . '.pdf';
    $mpdf->Output($m, 'F');
    $_SESSION['file'] = $m;

//$mpdf->Output();

    $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 = "dev@gmail.com"; // Who the email is from
    $email_subject = "Attached File"; // The Subject of the email
    $email_message = $emailBody;

    $email_to = 'dev2tricks@gmail.com'; // Who the email is to

    $headers = "From: " . $email_from;

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

    $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" .
            "--{$mime_boundary}--\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

Greetings..!

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.

Code:


<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" name="rotate" value="rotate" />
</form>
<?php
if(isset($_POST['rotate']))
{
    $image=$_FILES['image']['name'];
    $tmp_name=$_FILES["image"]["tmp_name"];
    $location='image/';
    echo $image;
    move_uploaded_file($tmp_name,$location.$image);
    $imagename = "image/".$image;
    $source= imagecreatefromjpeg($imagename);
    $rotate=imagerotate($source,75,0);
    imagejpeg($rotate,"rotated/$image");
}
if(isset($_FILES['image']['name']))
{
?>
<html>
<table>
<tr><td>UploadImage</td>
<td height="500px" width="500px" align="center">
<img src="image/<?php echo $image;?>" width="300px" height="300px" />
</td>
<td>RotateImage</td>
<td headers="500px" width="500px" align="center"><img src="rotated/<?php echo $image?>" width="300px" height="300px" /></td></tr>
</table>
</html>
<?php
}
?>


Output Screen
screen








How to Input string get Diamond shape Php

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

Code:


<form action="" method="post">
Enter the String : <input type="text" name="text" id="text" value="" />
<input type="submit" name="submit" id="submit" value="submit" />
</form>
<?php
error_reporting(0);
$string=$_POST['text'];
$len=strlen($string);
if(isset($_POST['submit']))
{
echo "<center>";
for($i=0;$i<$len;$i++)
{
for($j=0;$j<=$i;$j++)
{
echo $string[$j];
}
echo "<br>";
}
for($l=$i;$l>=0;$l--)
{
for($j=0;$j<$l;$j++)
{
echo $string[$j];
}
echo "<br>";
}
echo "</center>";
}

?>

Output Screen:


phpdiamond