Sunday, July 3, 2016

Pre requisites to learning PHP and MySQL

Pre-requisites

Before you continue you should have a basic understanding of the following:

  • HTML/XHTML
  • JavaScript

What is PHP?

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a server-side scripting language, like ASP
  • PHP scripts are executed on the server
  • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
  • PHP is an open source software
  • PHP is free to download and use

What is a PHP File?

  • PHP files can contain text, HTML tags and scripts
  • PHP files are returned to the browser as plain HTML
  • PHP files have a file extension of ".php", ".php3", or ".phtml"

What is MySQL?

  • MySQL is a database server
  • MySQL is ideal for both small and large applications
  • MySQL supports standard SQL
  • MySQL compiles on a number of platforms
  • MySQL is free to download and use

PHP + MySQL

  • PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform)

Why PHP?

  • PHP runs on different platforms (Windows, Linux, Unix, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • PHP is FREE to download from the official PHP resource: www.php.net
  • PHP is easy to learn and runs efficiently on the server side

Where to Start?

To get access to a web server with PHP support, you can:

  • Install Apache (or IIS) on your own server, install PHP, and MySQL
  • Or find a web hosting plan with PHP and MySQL support

PHP Installation

What do you need?

Most people would prefer to install a all-in-one solution:

WampServer 2.0i [07/11/09] ? for Windows platform Includes : - Apache 2.2.11 -

MySQL 5.1.36 - PHP 5.3.0

http://www.wampserver.com/en/

http://lamphowto.com/ for Linux platform

Already have a web server?

If your server supports PHP you dont need to do anything.

Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support. However, if your server does not support PHP, you must install PHP. Here is a link to a good tutorial from PHP.net on how to install PHP5:

http://www.php.net/manual/en/install.php

Download PHP

Download PHP for free here: http://www.php.net/downloads.php

Download MySQL Database

Download MySQL for free here: http://www.mysql.com/downloads/index.html

Download Apache Server

Download Apache for free here: http://httpd.apache.org/download.cgi

Download a nice text editor

http://www.flos-freeware.ch/notepad2.html

Ghazi Book by Abu Shuja Waqar

Ghazi by Abu Shuja Waqar

Ghazi Book in pdf real story
Ghazi is nice book of Pakistan Mujahid and army forces stories and specially I.S.I stories is written by abu Shuja Waqar


Saturday, July 2, 2016

Teesree lehar PDF Book

Teesree lehar

Teesree lehar PDF Book
In this PDF Book you will read struggle of people in 19 century, politics and many more thing of history.Teesree lehar is written by Toffler and translate in urdu Tanveer iqbal.

Maloomat Tareekh e Islam

Maloomat Tareekh e Islam

Maloomat Tareekh e Islam info pdf book
A Islamic Base Topic Book in Urdu PDF format.In the Maloomat Tareekh e Islam  First is given a Questions and then answer . A nice collection of Info.



reCAPTCHA Contact Form Receive Feedback From Your Visitors

This free php contact form makes receiving email or feedback from your visitors much easier. All your visitors have to do is fill out a simple contact form and hit send. Features reCAPTCHA image verification to reduce spam bots from submitting your form.

Requirements

    PHP 5.2+ – http://www.php.net
    reCAPTCHA API Key – http://www.google.com/recaptcha/whyrecaptcha

Installation

  •     First, you will need to signup for reCAPTCHA API key if you plan on using this feature. This will greatly reduce spam being submitted to your contact form. If you wish to bypass this feature, leave the API settings blank in inc/config.inc.
  •     Edit inc/config.inc to reflect additional settings such as defining custom emails for selection in the form. This allows you to send emails to different divisions of your organization.
  •     Upload the script files to your server.
  •     To modify the appearance of the contact form edit “inc/contact.php”. Just be careful not to destroy any PHP scripting while doing so.

Download reCAPTCHA Contact Form

PHP Delete Data From MySQL with Confirmation

This tutorial shows you that how to Delete rows From MySql database table and How to set JavaScript Powered Confirmation Message, When you click  or press delete link a confirmation message will appear and make sure to delete the selected data or not from MySql Database table  , When You press yes on confirmed messege it will delete the data if not it will do nothing with the data.


Read more »

HTML5 Form Validations with Pattern Matching

This is another Client Side Validation method No JavaScript or jQuery needed, Thanks to HTML5 because validations can now be done using HTML5 without coding of javascript or any server side language, using HTML5 you can validate forms with pattern, Forms must be validate either using client side or server side because it helps you to collect correct data or valid form values from the users, you cannot trust users blindly, let’s see it.
HTML5 Form Validation with Pattern Matching
Read more »

Friday, July 1, 2016

PHP Unlink Function

Remember from the PHP File Create lesson that we created a file named testFile.txt.

PHP Code:

$myFile = "testFile.txt";
$fh = fopen($myFile, w) or die("cant open file");
fclose($fh);

Now to delete testFile.txt we simply run a PHP script that is located in the same directory. Unlink just needs to know the name of the file to start working its destructive magic.

PHP Code:

$myFile = "testFile.txt";
unlink($myFile);

The testFile.txt should now be removed.

PHP - Unlink: Safety First!

With great power comes a slough of potential things you can mess up! When you are performing the unlink function be sure that you are deleting the right file!

Inqilab 1857 by P C Joshi

Inqilab 1857 by P C Joshi

Inqilab 1857 history book
       Urdu history PDF copy book  involving  "Inqilab 1857"  through  P C Joshi.Publish  via  peoples publishing house memories  for   following   complete  100 hundred years.  a complete  Discussing  about   an  old historical struggle  with  India .  


Generating excel xls files

Here we generate excel files from php script. To begin we will need some main excel classes as following:
1. BIFFwriter.php (for writing BIFF (binary file format)
2. Format.php (for generating excel XF records)
3. OLEwriter.php (OLE stream for spreadsheet)
4. Parser.php (for parsing excel formula)
5. Workbook.php (for generating excel workbook)
6. Worksheet.php (for generating excel worksheet)

You may want to see some examples in which you can download with all the six files above. You can download them all here (48kb) !!.

There are also five example files included:
1. example1.php (creating first example in generating excel document and comments are also included)
2. example2.php (set and modify fonts and styles)
3. example3.php (set columns and rows)
4. example4.php (set page)
5. example5.php (apply formula)

Link Manager Software

LinkMan link manager software will completely automate your link exchange! Here is how your reciprocal link exchange will work with LinkMan:

  • Webmaster John is interested in exchanging links with your site,
  • He ads a link to your website on his links page (or any other page on his website),
  • He submits the "Add a link" form on your site,
  • LinkMan verifies that a reciprocal link to your site has indeed been added,
  • A few more automated checks to verify everything is OK and the new link automatically appears on your links page!

Its that simple! In the LinkMan admin manager panel you have a special tool that will crawl all URLs where your reciprocal link should be. If a reciprocal link isnt found LinkMan will automatically remove the missing link from your links page.

LinkMan doesnt need a SQL database to operate, it works with simple text files. You can also easily edit header and footer of the links page so it will completely fit into the rest of your website!

LinkMan is rich with features:

  • automate your link exchange,
  • administration panel for easy control,
  • choose to manually approve and reject links,
  • mark links as featured,
  • display website thumbnails,
  • display Google PageRank,
  • block websites with too low PageRank,
  • block links with rel="nofollow" link attribute,
  • block links from pages with the meta robots noindex or nofollow tags,
  • powerful SPAM filter,
  • block superlatives from titles and descriptions,
  • block duplicate website submissions,
  • ban websites,
  • ... and much more!,

Download Link Manager Software

PHP Interview Questions Part 1

Common PHP Interview Questions

1. What is CAPTCHA?

CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. To prevent spammers from using bots to automatically fill out forms, CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. By entering the numbers and letters from the image in the validation field, the application can be fairly assured that there is a human client using it. To read more look here:
http://en.wikipedia.org/wiki/Captcha


2. What is difference between require_once(), require(), include().

Difference between require() and require_once(): require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you dont include the file more times and you will not get the "function re-declared" error. Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING. There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().


3. If you have to work with dates in the following format: "Tuesday, February 14, 2006 @ 10:39 am", how can you convert them to another format, that is easier to use?

The strtotime function can convert a string to a timestamp. A timestamp can be converted to date format. So it is best to store the dates as timestamp in the database, and just output them in the format you like.

So lets say we have
$date = "Tuesday, February 14, 2006 @ 10:39 am";
In order to convert that to a timestamp, we need to get rid of the "@" sign, and we can use the remaining string as a parameter for the strtotime function.

So we have
$date = str_replace("@ ","",$date);
$date = strtotime($date);

now $date is a timestamp
and we can say:

echo date("d M Y",$date);


4. How we know browser properties?

get_browser() attempts to determine the capabilities of the users browser. This is done by looking up the browsers information in the browscap.ini file.

echo $_SERVER[HTTP_USER_AGENT] . " ";

$browser = get_browser();

foreach ($browser as $name => $value) {
echo "$name $value
";
}


5. How i will check that user is, logged in or not. i want to make it a function and i want to use in each page and after login i want to go in current page(same page. where i was working)?

For this we can use the session objec($_SESSION)t. When the user login with his/ her user name and password, usually we check those to ensure for correctness. If that user name and password are valid one then we can store that user name in a session and then we can very that session variable has been set or not in a single files and we can include that file in all pages.

6. How i can get IP address?

We can use SERVER var $_SERVER[SERVER_ADDR] and getenv("REMOTE_ADDR") functions to get the IP address.

7. What is differenc between mysql_connect and mysql_pconnec?

mysql_pconnect establishes a persistent connection. If you dont need one (such as a website that is mostly HTML files or PHP files that dont call the db) then you dont need to use it. mysql_connect establishes a connection for the duration of the script that access the db. Once the script has finished executing it closes the connection. The only time you need to close the connection manually is if you jump out of the script for any reason.

If you do use mysql_pconnect. You only need to call it once for the session. Thats the beauty of it. It will hold open a connection to the db that you can use over and over again simply by calling the resource ID whenever you need to interact with the db.

8. What is the difference between echo and print statement?

There is a slight difference between print and echo which would depend on how you want to use the outcome. Using the print method can return a true/false value. This may be helpful during a script execution of some sort. Echo does not return a value, but has been considered as a faster executed command. All this can get into a rather complicated discussion, so for now, you can just use whichever one you prefer.

9. How to make a download page in own site, which i can know that how many file has been loaded by particular user or particular IP address?

We can use hyperlink having URL where file are kept. and we only allow registered user to download. from session of user we can get the user detail