Monday 23 December 2013

How to Attacch File/Image From External URL(remote file/image) to e-mail


How to Attacch File/Image From External URL to e-mail Iam Previously explain about sending e-mails using PHPmailer and Gmail server in this added a code for attachment File/Image from Folder But
Now i'am Explain about how to attach a File/Image from External URl.

General File/Image attachemnet:
$mail->AddAttachment("images/kc_logo.jpg");
File/Image attachment from Remote:
$string = file_get_contents("http://sri-knowledgecorner.rhcloud.com/images/blogicon.jpeg"); 

$mail->AddStringAttachment($string, "01182013_220715.jpg", $encoding = 'base64', $type = 'application/octet-stream');
In case file_get_cotents field to load file use cURL,
Read More info about file_get_contents and cURL Click Here

Saturday 21 December 2013

How To Validate Email, URL And IP in PHP


How To Validate Email, URL And IP in PHP I know to most PHP programmers, this isn’t a big deal. I am going to show us, how to validate Email, URL and IP address using their respective PHP validation function.
It is very important input by users are validated before they are sent for processing. Not validating what users enter can lead to a very big security breach and could make your website susceptible to hackers. PHP has a large number of filters for validation and sanitization, but we’re only going to see that of the Email, URL and IP address.
Let’s take a look at these validation filters and how they work.

Validating Email:
Function :– filter_var($value, FILTER_VALIDATE_EMAIL)
<?php
 $email = "knowledgecorner@gmail.com";
 if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
 echo "This ($email) email is valid.";
 }
 else {
 echo "This ($email) is not valid.";
 }
?>
Validating URL:
Function – filter_var($value, FILTER_VALIDATE_URL)
<?php
 $url = 'knowledgecorner.com';
 if (filter_var($url, FILTER_VALIDATE_URL)) {
 echo "This ($url) URL is valid.";
 }
 else {
 echo "This ($url) URL is not valid.";
 }
?>
Validating IP address:
Function – filter_var($value, FILTER_VALIDATE_IP)
<?php
 $ip = '10.199.212.2';
 if (filter_var($ip, FILTER_VALIDATE_IP)) {
 echo "This ($ip) IP address is valid.";
 }
 else {
 echo "This ($ip) IP address is not valid.";
 }
?>

Thursday 19 December 2013

Sending e-mail using SMTP server of Gmail with PHP.


Sending e-mail using SMTP server of Gmail with PHP. This article is about send emails in SMTP(Simple Mail Transfer Protocol) using phpmailer by gmail server,
Here we are using PHPMailer for send emails using SMTP in php
It is very easy process.....


Tuesday 17 December 2013

Get longitude & latitude values with Google Maps API using PHP


Get longitude & latitude with Google Maps API get the latitude and longitude values from Google Maps API, based on the town, city or country location.
<?php
  $url = "http://maps.google.com/maps/api/geocode/json?address=hyderabad&sensor=false&region=IN";
  $response = file_get_contents($url);
  $response = json_decode($response, true);
 
  //print_r($response);
 
  $lat = $response['results'][0]['geometry']['location']['lat'];
  $long = $response['results'][0]['geometry']['location']['lng'];
 
  echo "latitude: " . $lat . " longitude: " . $long;
?>
The http://maps.google.com/maps/api/geocode/json URL takes in 3 parameters: address (your main location), region (optional but can help with ambiguity) and sensor (indicates whether or not the request will come from a device with a locational sensor).
The print_r command commented out above is a useful way to work out the array structure that you need to drill down to. To get the longitude and latitude values, we need to drill down through 5 levels.

More Info vist: developers.google.com

Friday 13 December 2013

Delete file/image in cakephp


Delete images in cakephp For instance, you would like to delete car.jpg under YOUR WEBROOT/img folder.
First, you construct a File object:
App::uses('File', 'Utility');

$file = new File(WWW_ROOT .'img/car.jpg',false, 0777);

if($file->delete()){
   echo "file/image deleted successfully";
}else{
   echo "file/image failed to be delete";
}
$file->delete() return true when the file has successfully been deleted. Hence, we check for successions of file deletion using the if statement as shown above.
*** I hope this Post helps to You ***

Wednesday 11 December 2013

How To Browse More Securely in Cyber Cafe or on Public PCs ?


How To Browse More Securely in Cyber Cafe or on Public PCs ? Learn on the serious topic of how you can browse more securely on others/Public PCs or when you are in Cyber Cafe.Yes , it is a very serious topic that how you can browse whenever are far from your personal PC and at that time you have to browse from any cyber cafe without any idea of whether the Systems are secure or not for browsing , and you have to open your important online accounts like Internet banking ,Credit/Debit Card transactions , Official Email-IDs ,Blogging Account and Social networking account like(Facebook,Twitter,LinkedIn) which shows your virtual or vital public presence .Without knowing how others manage their system security , you signing in to your account and a day you will shocked that your account have been misused and you do not know anything about what happened , why happened.


Monday 9 December 2013

Meta Tags and its importances


What is Meta Tags and Use of Meta Elements Meta Tags or Meta Elements are the HTML or XHTML elements used to provide structured meta data about the web page. It may contain the page description, keywords or about robot etc.. This meta tags plays a major role in Search Engine Optimization (SEO). it place between the <head> and </head> tag.


Saturday 7 December 2013

Using PHP Generate Excel Report From Database


When developing a website that uses a database, quite often there would be a requirement to store dynamic data in a table, whether that be contact form entries, activity logs, or even lists of registered users.


While that data can be easily extracted directly from the database using database software, you may need to export that data using a web application. The following code is some useful PHP that can be used to take all data from a MySQL table and export them in a Excel format, that can be downloaded by the user as a Excel sheet.

Friday 6 December 2013

Disable back button of your browser using javascript(Cross browser compatible)


It is an interesting browser hack and which uses hash values to prevent the default functionality of browser back button.But it and can be very annoying to use in your website and may be your user can dump your website . So please don't use that until if you have a really valid reason for it.

just at the top of your script .It set the hash value to 'no-back-button' at the time of page load.
window.location.hash="no-back-button"; 

Wednesday 4 December 2013

Ubuntu 12.04 can’t connect to the internet


It seems this is a common problem with an easy fix.
sudo apt-get remove --purge resolvconf
After that Restart your Networ, Using following command.
sudo /etc/init.d/networking restart
OR
sudo service network-manager restart