Saturday, August 21, 2010

Retirement Benefits Package - a small project that I did in office..



I had done a Retirement Benefits Package for my offiice. Please check this link out to take a look at my project.. though it's a small one.. still, hope u'll like it..http://retbenefitshomepage.zymichost.com/ I used PHP/MySql which was basically set up on a standalone server in my machine. Since it was LAN-connected, all branches of my company over the country could access it. But I was thinking of making a repository for the whole lot of thing in a web. Then I started looking for free php web-hosting and found Zymichost which did the wonder! It provides you with the following details:


DetailsSpecifications
Disk space: 5000MB
Control Panel: ZHCP
Number of Accounts: Unlimited (u can host as many websites with us as you like)
File Manager/FTP Access: Allows Upload, edit, rename, and delete files instead of using FTP
PHP: Ver 5.2.12 (latest one)
MySQL Database: Accepts a total of 3 MySQL database accounts
SQLBuddy: Allows advanced MySQL database management with all advanced query set-up
Sub-Domains: Allows a range of choices such as 99k.org, zxq.net, zymichost.com
TLD Domain: Allows u to use your own domain on their hosting
My overall rating : GOOD








Here are some snapshots of my project..






Homepage 

Form for Gratuity Calculation
Form for Monetary Compensation Calculation
Editable Gridview of Database (allows CRUD operation: Create/Read/Update/Delete)

Administrator's Homepage

Different Report Generation

Hope u've liked my small work.. I wish one day I'll develop my own website and host it without any cost in Zymic. It's of great help to provide such a helping hand to all budding developers. Thanks Zymic!! :)















Thursday, August 19, 2010

Configure BSNL Broadband in Ubuntu

Got the Ubuntu 10.04 free CD from https://shipit.ubuntu.com/ that day.. I was struggling for configuring BSNL broadband connection in it.. These are the steps those helped..


Step 1:
Go to your Network control panel.
Follow steps : Taskbar >> System >> Administration >> Network.

Step 2:
Then click on the Unlock button and then it will ask for Administrative password, Enter your Password. and click Authenticate so that it will unlock the locked features.

Step 3:
Click on Wired connection and then its properties, it will show you “Connection setting tab” select “Automatic configuration (DHCP)” from the list and click OK.

Step 4
Select Point to Point connection, and go to its properties. It will pop up the pppo properties.
Check the “Enable this connection”, and select “PPPoE connection type” and Enter the account data (Username and Password)in specified boxes,

Step 5:
Go to Modem tab from same Window, select the Ethernet interface (Generally the eth0)
Go to option tab select all check boxes. and then OK. and close.

Now everytime you want to connect to net, just click on LAN Icon on taskbar and go to Dial Up connections and click on Connect to pppOe via modem and get connectiviy.

So now just start your Firefox and start browsing the internet from your Ubuntu. 

Note: This guide is for LAN connection only, and not for the USB connections as many modem manufacturer doesn't provide drivers for Linux versions.

Sunday, July 11, 2010

New Way of Generating URL-shortener using PHP

The most famous URL shortener which I've come across so far is Tinyurl. But recently I've seen another one called "bit.ly". Here you can shorten your long URLs using bit.ly : click. Here we're going to discuss about writing small script using PHP through which you can shorten the long URLs. Though I've come across many, I'd like to share here the weirdest process by making folder..!! Really! I found it in Youtube Video Tutorials.. Please check it out.. It doesn't require any database creation even!

Screenshot of index.php


















Screenshot of process.php



Here is the Part-I (click here for the youtube video)




Here is the Part-2 (click here for the youtube video)

Friday, July 09, 2010

PHP simplest log-in script








Overview
Create 3 files
1. main_login.php
2. checklogin.php
3. login_success.php

Steps
1. Create table "members" in database "test".
2. Create file main_login.php.
3. Create file checklogin.php.
4. Create file login_success.php.
5. Create file logout.php


Create table "members"    



CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
--
-- Dumping data for table `members`
--
INSERT INTO `members` VALUES (1, 'chandrima', '1234');

Create file main_login.php








//Code





Create file checklogin.php
//Code
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form 
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 

header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>




Create file login_success.php

//Code
// Check if session is not registered , redirect back to main page. 
// Put this code in first line of web page. 
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>



Login Successful

Logout.php

If you want to logout, create this file

// Put this code in first line of web page. 
session_start();
session_destroy();
?>

For PHP5 User - checklogin.php


//Code
ob_start();
$host="localhost";
 // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword 
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 

header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}

ob_end_flush();
?>







Monday, May 24, 2010

Calculate free space on drive using DOS

Run the following from SQL Server to check out the free space amount on a drive.

1. @echo off >nullfile.txt

2. set Drive=C:
3. for /F "tokens=7" %%a in ('fsutil volume diskfree %Drive% ^find /i  "# of free" ')
4.       do set free=%%a
5. set free=%free:~0,-6%
6. echo c: %free%


Now, the following will run a bat file to get free space on a drive and write the results to a table.

  • IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.tables WHERE table_name = 'FreeSpace') DROP TABLE FreeSpace


  • CREATE TABLE FreeSpace ( SpaceInMB varchar(100) NULL )

  • INSERT INTO FreeSpace EXEC master..xp_CMDShell 'C:\Scripts\FreeSpace.bat'

Sunday, May 23, 2010

Simplest File Upload in PHP

In many websites, we need to upload files like: our CVs in different job sites, our profile pictures in different social sites etc. It's very useful, and sometimes it has certain restrictions too.. like: you can upload a picture having maximum upper bound of 25MB size etc. Using php scripts, file uploading can be done easily through the following few steps.


Create an Upload-File Form using plain HTML 

(click here to view the code)



Create The Upload Script using PHP 

(click here to view the code)




By using the global PHP $_FILES array you can upload files from a client computer to the remote server.
The first parameter is the form's input name and the second index can be either "name", "type", "size", "tmp_name" or "error". Like this:
  • $_FILES["file"]["name"] - the name of the uploaded file
  • $_FILES["file"]["type"] - the type of the uploaded file
  • $_FILES["file"]["size"] - the size in bytes of the uploaded file
  • $_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server
  • $_FILES["file"]["error"] - the error code resulting from the file upload
This is a very simple way of uploading files. For security reasons, you should add restrictions on what the user is allowed to upload.

Restrictions on Upload 

In this script we add some restrictions to the file upload. The user may only upload .gif or .jpeg files and the file size must be < 20 KB











Saving the Uploaded File 

(click here to view the code)

The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location.


Saturday, May 22, 2010

First PHP-Mysql Data-Connectivity Project

A very small project on php-mysql data connectivity I'm going to upload here.. Beginners may find it useful. I had to learn everything from the scratch just by going through different websites on php. W3schools is really a good way to start. I didn't use full Php 5.2 and Apache server installation. I just installed XAMPP. Later, I found another small sized version of it, called "xampplite". It's lightweight. And it works cool.

file 1: birthdays_create_table.php (click here to see the code)
file 2: birthdays_dbase_interface.php (click here to see the code)
file 3: birthdays_insert_form.php (click here to see the code)
file 4: birthdays_insert_record.php (click here to see the code)
file 5: birthdays_change_form.php (click here to see the code)
file 6: birthdays_change_record.php (click here to see the code)
file 7: birthdays_update_form.php (click here to see the code)
file 8: birthdays_delete_form.php (click here to see the code)
file 9: birthdays_delete_record.php (click here to see the code)
file 10: birthdays_display_records.php (click here to see the code)

For all files see this link