Translate

Showing posts with label simple. Show all posts
Showing posts with label simple. Show all posts

Tuesday, May 31, 2016

Simple php script for making Excel files

Simple PHP script for making Excel files



This tutorial describes a simple way to generate Microsoft excel file from the php script. As you notice that, there are a lot of complicated external libraries for this purpose (like phpexcel etc.). Here I am describing a simple way to generate excel files without using any external libraries.

Please copy following php code to your web server and run the file. You can see that, a spreadsheet automatically generated there and you can download the same. The contents in the excel file are the same which is given in the code.


<?php
            header( "Content-Type: application/vnd.ms-excel" );
            header( "Content-disposition: attachment; filename=spreadsheet.xls" );
            // print here what you want to see in excel for example:
            echo 'First Name' . "\t" . 'Last Name' . "\t" . 'Mobile' . "\n";
            echo 'Praveen' . "\t" . 'Thappily' . "\t" . '999999999' . "\n";
?>


I believes that this code is self explanatory. The file name should be given in the second header tag. Here the file name is “spreadsheet.xls”. It can be noted that, for changing excel column, you have to use the tab (\t”) switch and similarly to goto the next row you need to use new line switch  (“\n”) in the code as demonstrated above. Figure below shows typical output excel file.

You can use the same file for making excel file from your database (mysql or mssql), just read it using select query and echo the contents. if any doubt please contact us
info.pravysoft@gmail.com
www.pravysoft.org

Thursday, March 5, 2015

Simply use WHATSAPP in your computer !!!






Even though there is no official whatsapp software work in personal computer, you can access whatsapp in PC using various techniques. For example, with the help of Blue stack software you can install this software on your PC. But in this case you can access whatsapp only in one device (either on PC or Phone)  [Whatsapp team always checking your MAC ID for this purpose]. Switching from one device to another is also a time consuming process (SMS or Voice validation is needed each time). So as a solution for this problem whatsapp team introduced a new technique. Now you can use whatsapp in your computer browser


To get startedplease follow these simple steps

  • Please update your whatsapp application(in phone) to the latest one.
  • Connect your phone and computer  to the internet
    (Recommanded wifi connection in mobile for better performance)
  •   Open Firefox or google chrome browser in your computer


·         Now you can see, a QR code displayed in the website. (A black square, something like a Bar code with whatsapp icon in the center)

  • open your whatsapp application in your phone (Internet connection is required)

  • Now go to Menu and select WhatsApp Web. (Check whatsapp menu)
  • Scan the QR Code displayed on your computer (in the browser)with your phone.
[Place your phone camera infront of your PC and capture QR code (like taking a photo)]
  • Now whatsapp will show all contacts and chat list in the PC. You can chat with your friends through your PC as like facebook chat. So keep your phone away and enjoy whatsapp chating through your PC keyboard.

Wednesday, January 23, 2013

Send SMS from JSP ASP and PHP projects

EASY Way to sens message (SMS) from your project

In this post I would like to explain how you can send sms from your web project. You can use any programming language. The method successfully worked out using PHP, JSP and ASP Platforms.






PravySoft SMS senter

Please do following steps

1)First you need an 160by2.com account. 
You will get free 160by2 account from this website
 http://160by2.com

2) Writedown your  username and password
 Normally username would be your Mobile Phone number

3)From your project call this web link with your username password and message as shown below

http://pravysoft.eu5.org/sms.php?username=xxx&password=yyy&button=1&to=zzz&msg=abcd


Please replace
XXX with your username
YYY with password
ZZZ with Mobile number of the recipient
ABCD with your msg.


Example PHP script

This is a simple code for demonstration of the method. Please use url encode function and POST method (to hide username password from url) for implementation.

<?php
$username="your username";              // username you got from 160by2.com website
$password="your password";             //your password
$to="99956xxxxx";                           //Phone number to send msg
$msg="TEST";                //Message to  send you can use url encode function if space exist in your message
echo('<a href="http://pravysoft.eu5org/sms.php?username='.$username.'&password='.$password.'&button=1&to='.$to.'&msg='.$msg.'">SEND SMS</a>');
?>


You can send sms (Text messgaes) using JSP and ASP using similar way.

If you want to know more or need codes please ask to me

info.pravysoft@gmail.com

or visit



Monday, March 7, 2011

webspider


PHP web spider
Tutorial below shows how to make custom search engine by using yahoo boss api. If you're looking for search engine customization, then building your own search engine is something you'll want to look into. Here we are using an api provided by yahoo search service. Search APIs are nothing new, but typically they've included rate limits, strict terms of service regarding the re-ordering and presentation of results, and provided little or no opportunity for monetization. 

These constraints have limited the innovation and commercial viability of new search solutions. The name of the api is BOSS.
BOSS (Build your Own Search Service) is different; it's a truly open API with as few rules and limitations as possible. With BOSS, developers and start-ups now have the technology and infrastructure to build next generation search solutions that can compete head-to-head with the principals in the search industry.
Now we can go through the code
At first you need to create an HTML web search page as shown below

pravysoft



search




you will get a text box ,shown below
pravysoft<span style="">  </span>web search
search
Here I am created a text box with name “search” and a submit button. Here I am used POST method for sending form variables. For simple usage action=””, which means post the information on the same page.
Now we can look on the main code for web search engine.
if(isset($_POST['submit']))
{
$search=$_POST['search'];
$request="http://boss.yahooapis.com/ysearch/web/v1/".$search."?format=xml&appid=Uz.......................";
//replace appid with your id
$ch = curl_init($request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$xml = simplexml_load_string (curl_exec($ch));
// Display search results - Title, Date and URL.
foreach ($xml->resultset_web->result as $result) {
 print ''.$result->title.'
';
}
}
?>

At first you can see isset($_POST['submit']) code .which checks whether user clicked on the submit button or not. if this function returns 1.that means user clicked on the button.Then read the contents of the text box with the help of POST function.on the next step you have to replace “ appid” with your own BOSS id


You will get api id from yahoo boss web site BOSS web site
after replace the pravysoft appid with your own boss id .you can easily make your own web spider.
Now we can go through the PHP cURl function.cURL is a library which allows you to connect and communicate to many different types of servers with many different types of protocols. Using cURL you can:
  • Implement payment gateways’ payment notification scripts.
  • Download and upload files from remote servers.
  • Login to other websites and access members only sections.
PHP cURL library is definitely the odd man out. Unlike other PHP libraries where a whole plethora of functions is made available, PHP cURL wraps up major parts of its functionality in just four functions.
A typical PHP cURL usage follows the following sequence of steps.
curl_init – Initializes the session and returns a cURL handle which can be passed to other cURL functions.
curl_opt – This is the main work horse of cURL library. This function is called multiple times and specifies what we want the cURL library to do.
curl_exec – Executes a cURL session.
curl_close – Closes the current cURL session.
Please note that our BOSS api returns output as simple xml format.which contains information like click url,title etc.So we have to convert the xml data and to access the click url its better to insert xml parsed datum into an array.
Here I used an array $result to store xml parsed data. Then with the help of foreach loop, I separated each title and click url by giving necessary indexes to the result array and placed necessary places of the HTML page.
Complete code below
if(isset($_POST['submit']))
{
$search=$_POST['search'];
$request="http://boss.yahooapis.com/ysearch/web/v1/".$search."?format=xml&appid=Uz.I................";
$ch = curl_init($request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$xml = simplexml_load_string (curl_exec($ch));
// Display search results - Title, Date and URL.
foreach ($xml->resultset_web->result as $result) {
 print ''.$result->title.'
';
}
}
?>

pravysoft


search