My name is Shefeek Jinnah.I am a Software Engineer by profession.I completed my graduation from Mar Athanasious College Of Engineering,Kothamangalam,Kerala in the year 2008.Coding is my passion and technical expedition is my pursuit.
I have been writing technical blogs for the last few years.But i find myself difficult in managing all the blogs and communities.So i decided to combine all my blogs and keep it under a single roof and here it is.The intention of this website is to share information so that it will be useful for me as well as for the visitors.I will post everything technicaly that goes through my head daily and which i am involved in.
I offer free technical assistance though the discussion forum of this website.You can ask me for any technical assistance.I will provide you with enough information if it is within my range or i can get you the details soon after consulting with my senior’s
http://www.shefeekj.com/
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Monday, January 26, 2009
Wednesday, December 3, 2008
Uploading a file
$uploadedImage = new Upload($_FILES['uploadImage']);
if ($uploadedImage->uploaded) {
$uploadedImage->Process('myuploads');
if ($uploadedImage->processed) {
echo 'file has been uploaded';
}
}
if ($uploadedImage->uploaded) {
$uploadedImage->Process('myuploads');
if ($uploadedImage->processed) {
echo 'file has been uploaded';
}
}
List files in the directory
List all files in a directory and return an array.
function dirList ($directory) {
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
// if $file isn't this directory or its parent,
// add it to the results array
if ($file != '.' && $file != '..')
$results[] = $file;
}
// tidy up: close the handler
closedir($handler);
// done!
return $results;
}
function dirList ($directory) {
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
// if $file isn't this directory or its parent,
// add it to the results array
if ($file != '.' && $file != '..')
$results[] = $file;
}
// tidy up: close the handler
closedir($handler);
// done!
return $results;
}
Force Downloading a file
Forces a user to download a file, for e.g you have an image but you want the user to download it instead of displaying it in his browser.
header("Content-type: application/octet-stream");
// displays progress bar when downloading (credits to Felix ;-))
header("Content-Length: " . filesize('myImage.jpg'));
// file name of download file
header('Content-Disposition: attachment; filename="myImage.jpg"');
// reads the file on the server
readfile('myImage.jpg');
header("Content-type: application/octet-stream");
// displays progress bar when downloading (credits to Felix ;-))
header("Content-Length: " . filesize('myImage.jpg'));
// file name of download file
header('Content-Disposition: attachment; filename="myImage.jpg"');
// reads the file on the server
readfile('myImage.jpg');
Random Password Generator
PHP password generator is a complete, working random password generation function for PHP. It allows the developer to customize the password: set its length and strength. Just include this function anywhere in your code and then use it.
Source : http://www.webtoolkit.info/php-random-password-generator.html
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength & 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength & 2) {
$vowels .= "AEUY";
}
if ($strength & 4) {
$consonants .= '23456789';
}
if ($strength & 8) {
$consonants .= '@#$%';
}
$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}
Source : http://www.webtoolkit.info/php-random-password-generator.html
function generatePassword($length=9, $strength=0) {
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength & 1) {
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength & 2) {
$vowels .= "AEUY";
}
if ($strength & 4) {
$consonants .= '23456789';
}
if ($strength & 8) {
$consonants .= '@#$%';
}
$password = '';
$alt = time() % 2;
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand() % strlen($consonants))];
$alt = 0;
} else {
$password .= $vowels[(rand() % strlen($vowels))];
$alt = 1;
}
}
return $password;
}
Uniform Server
The Uniform Server is a WAMP package that allows you to run a server on any MS Windows OS based computer. It is small and mobile to download or move around and can also be used or setup as a production/live server. Developers also use The Uniform Server to test their applications made with either PHP, MySQL, Perl, or the Apache HTTPd Server. The main advantage is that no installation is required.You can just copy the folder to any system and set up the server in that machine.You can even carry your server in a thump drive
Download Link :https://sourceforge.net/project/showfiles.php?group_id=53691
Download Link :https://sourceforge.net/project/showfiles.php?group_id=53691
WAMP Server
WAMP server is one of the most important software that makes PHP an amazing languange.IF you want to start coding in php,you can just make your system ready for programming in minutes using WAMP server.The WAMP server is a software package which brings the following things under a single roof
1.Apache - webserver
2.MySql - Database
3.PHP 5 -Compiler
4.Php My Admin - Interactive Database Management
WAMP Download Page :http://www.wampserver.com/en/download.php
Installing
Double click on the downloaded file and just follow the instructions. Everything is automatic. The WampServer package is delivered whith the latest releases of Apache, MySQL and PHP.
Once WampServer is installed, you can add other releases by downloading them on this website. They will then appear in the WampServer menu and you will be able to switch releases with a simple click.
Each release of Apache, MySQL and PHP has its own settings and its own files (datas for MySQL).
Functionalities
WampServer's functionalities are very complete and easy to use so we won't explain here how to use them.
With a left click on WampServer's icon, you will be able to:
- manage your Apache and MySQL services
- switch online/offline (give access to everyone or only localhost)
- install and switch Apache, MySQL and PHP releases
- manage your servers settings
- access your logs
- access your settings files
- create alias
With a right click :
- change WampServer's menu language
- access this page
How to start ?
When you install WampServer, a "www" directory is created (generally c:\wamp\www). Create a directory inside for your project and put your PHP files in it.
Click on the link "Localhost" in the WampServer menu or open your browser and open the http://localhost address.
Add Apache, MySQL and PHP releases
WampServer allows you to install almost all the existing releases of Apache, PHP and MySQL so you can reproduce exactly the settings of your production server.
To add a new release, donwload it here and install it.
Then click on the WampServer menu and activate the release that you want to use.
Wait until the WampServer icon become white again and start to work.
1.Apache - webserver
2.MySql - Database
3.PHP 5 -Compiler
4.Php My Admin - Interactive Database Management
WAMP Download Page :http://www.wampserver.com/en/download.php
Installing
Double click on the downloaded file and just follow the instructions. Everything is automatic. The WampServer package is delivered whith the latest releases of Apache, MySQL and PHP.
Once WampServer is installed, you can add other releases by downloading them on this website. They will then appear in the WampServer menu and you will be able to switch releases with a simple click.
Each release of Apache, MySQL and PHP has its own settings and its own files (datas for MySQL).
Functionalities
WampServer's functionalities are very complete and easy to use so we won't explain here how to use them.
With a left click on WampServer's icon, you will be able to:
- manage your Apache and MySQL services
- switch online/offline (give access to everyone or only localhost)
- install and switch Apache, MySQL and PHP releases
- manage your servers settings
- access your logs
- access your settings files
- create alias
With a right click :
- change WampServer's menu language
- access this page
How to start ?
When you install WampServer, a "www" directory is created (generally c:\wamp\www). Create a directory inside for your project and put your PHP files in it.
Click on the link "Localhost" in the WampServer menu or open your browser and open the http://localhost address.
Add Apache, MySQL and PHP releases
WampServer allows you to install almost all the existing releases of Apache, PHP and MySQL so you can reproduce exactly the settings of your production server.
To add a new release, donwload it here and install it.
Then click on the WampServer menu and activate the release that you want to use.
Wait until the WampServer icon become white again and start to work.
Post & Get
Receiving variables using GET Method
$variablename = $_GET['formvariablename'];
Note :The get method passes the variables along to the the php page from the form page by appending them onto the end of the URL.
For example if the form is in the page formpage.html and the php page is submit.php .
Inside the form tag it will be like form action="submit.php" method="get"
Suppose there is a textbox inside the form named txt.When we click the button,it will direct to the url submit.php?txt="Text in the textbox"
Receiving variables using POST Method
$variablename = $_POST['formvariablename'];
Note :The POST method passes the variables along to the the php page as bytes of data,not appending to the url.
$variablename = $_GET['formvariablename'];
Note :The get method passes the variables along to the the php page from the form page by appending them onto the end of the URL.
For example if the form is in the page formpage.html and the php page is submit.php .
Inside the form tag it will be like form action="submit.php" method="get"
Suppose there is a textbox inside the form named txt.When we click the button,it will direct to the url submit.php?txt="Text in the textbox"
Receiving variables using POST Method
$variablename = $_POST['formvariablename'];
Note :The POST method passes the variables along to the the php page as bytes of data,not appending to the url.
Tuesday, December 2, 2008
Sending an email in PHP
Simple Mail
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";?>
Html Mail (You can use images and other tags in mail)
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = 'Insert your html code here';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary , Kelly ' . "\r\n";
$headers .= 'From: Birthday Reminder ' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";?>
Html Mail (You can use images and other tags in mail)
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = 'Insert your html code here';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary , Kelly ' . "\r\n";
$headers .= 'From: Birthday Reminder ' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
Subscribe to:
Posts (Atom)
