Archive for May 2012

opens a directory with opendir() in php

open.php :

<?php
//Open send directory
if(@$dir = opendir("send"))
{
//List files in send directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
}
else
{
echo 'directory not opened';
}
?>

output :
 1)
directory not opened

2)
filename: .
filename: ..
filename: sendsms.html
filename: sendsms.php
filename: send_vard.php
filename: send_vcard_sms.html
filename: smser.php

Generate random password


/**
* Generate a random character array from the list of $possible characters
*
* @param array $possible Array of possible characters
* @param int $length Length of string to generate
* @return array An array of $length random characters
*/
function randomStringArray($possible, $length) {
$stringArray = array();
$possibleCount = count($possible);

$i = 0;
while ($i < $length) {
// pick a random character from the possible ones
$char = $possible[mt_rand(0, $possibleCount - 1)];

// we don't want this character if it's already in the password
if (!in_array($char, $stringArray)) {
$stringArray[] = $char;
$i++;
}
}

return $stringArray;
}

/**
* Generate password that contains 6 letters and 2 numbers
*/
function generatePassword() {
$letters = array_merge(range('a', 'z'), range('A', 'Z'));
$numbers = range('0', '9');
$chars = array_merge(
randomStringArray($letters, 6), randomStringArray($numbers, 2));
shuffle($chars);
return implode('', $chars);
}

About me and PHP

Hello World

My name is Sco Sban Wart :) It is my blog :) I will write about php security and put some interesting information from the net.

PHP is a very popular language. Every PHP developer and hoster should understand the primary attack vectors being used by attackers against PHP applications.

This article is the underlying research behind the SANS Top 20 2005's PHP section. The methodology used in the preparation of this article is to review all Bugtraq postings containing the word "PHP" and categorize each unique flaw. The author analyzed the most popular flaws / attacks, and researched prevention techniques, resulting in this article.

Form Validator

<script Language="JavaScript">
function FormValidator(theForm){
if (theForm.Name.value==""){
alert("Please enter your name.");
theForm.Name.focus();
return (false);
}
if (theForm.Subject.value==""){
alert("Please enter the subject");
theForm.Subject.focus();
return (false);
}
return (true);
}
</script>

<form method="POST" action="add.php" onsubmit="return FormValidator(this)" name="FormName">
<p>
Name : <input type="text" name="Name" size="20"><br>
Subject : <input type="text" name="Subject" size="20"><br>

<input type="submit" value="Submit" name="Submit"> <input type="reset" value="Reset" name="Reset">
</p>
</form>

file write in php

<?php

if(isset($_POST['name'])&&isset($_POST['age'])&&isset($_POST['fname']))
{
  $name=$_POST['name'];
  $age=$_POST['age'];
  $fname=$_POST['fname'];
  if(!empty($name)&&!empty($age)&&!empty($fname))
  {
    $hand=fopen($fname.'.txt','w');
    fwrite($hand,$name." ");
    fwrite($hand,$age."\r\n");
    fclose($hand);
  }
 else
    echo 'fill all fields';
}
?>

<form action="file-write.php" method="POST">
name :<input type="text" name="name">
age :<input type="text" name="age">
file name : <input type="text" name="fname">
.txt
<input type="submit" value="submit">
</form>

output :


note :
1) enter all fields
2) the last field is file name
3) first it clears all data from that file and write you entered data into that file
4)if that file not exists then it creates and write that file

Connecting to server, create database and creating table

exercise 1
connect to apache server root and the password, then create a database and to create table.
use this php code

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

if (mysql_query("CREATE DATABASE alex",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }

// Create table
mysql_select_db("alex", $con);
$sql = "CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";

// Execute query
mysql_query($sql,$con);

mysql_close($con);
?>

পিএইচপি অ্যারে

আমরা আগে ভেরিয়েবলের ব্যবহার দেখেছি। ভেরিয়েবলে আমরা বিভিন্ন তথ্য রাখতে পারি। ভেরিয়েবলে একটা সমস্যা হচ্ছে একই রকমের অনেকগুলো তথ্য একটি ভেরিয়েবলে রাখা যায় না। যদি অনেকগুলো তথ্য ভেরিয়েবলে আপনি রাখেন তাহলে ভেরিয়েবল সেটাকে একটি তথ্য ধরে নেয়। এই সমস্যা দূর করার জন্য আমরা পিএইচপিতে অ্যারে ব্যবহার করি। পিএইচপি অ্যারে একই রকমের তথ্যগুলোকে সংরক্ষণ করে। অর্থাৎ অনেকগুলো ভেরিয়েবলকে আমরা একটি অ্যারের মধ্যে রাখতে পারি। আমাদের ভিডিও টিউটোরিয়ালটি দেখলে আপনি ভেরিয়েবল এবং অ্যারে কি এবং তার মধ্যে পার্থক্য অনুধাবন করতে পারবেন। তাহলে আমরা একটি অ্যারে তৈরি করে দেখি। মনে করুন আমরা একটি অ্যারের মধ্যে অনেকগুলো কাস্টমারের নাম রাখব। নিচের কোডটি দেখুন

<?php
$customers=array("Sharif","Rahim","Karim","Shuvo");
echo $array[1];
?>

কোডটা যেকোন নাম দিয়ে সেভ করে রান করুন। দেখুন আউটপুট কি আসে। সাধারণত অ্যারে লিখতে হলে array লিখাটি দিতে হবে। এখন একটি গুরুত্তপূর্ন কথা বলব। অ্যারে ইনডেক্স শূন্য থেকে শুরু হয় কখনো এক থেকে নয়। একারনে উপরের কোডটা রান করলে Rahim নামটা দেখাবে। এখন আরেকটি উদাহরণ দেখুন।

<?php
$number=array(10,22,20,50);
echo $number[0]
?>
কোডটা রান করুন তাহলে অ্যারে ইনডেক্স কিভাবে কাজ করে তা আপনি বুঝতে পারবেন। আমরা অ্যারেকে তিনভাগে ভাগ করতে পারি।
(১) নিউমেরিক্যাল
(২) এসোসিয়েটিভ অ্যারে  
(৩) মাল্টি ডাইমেনশনাল অ্যারে

নিউমেরিক্যাল অ্যারে আপনি যখন অ্যারে ইনডেক্স নিউমেরিক নাম্বার দ্বারা ডিফাইন করে দেন তখন আমরা একে নিউমেরিকাল অ্যারে বলব। যেমন

<?php
$customer[0]="Sharif";
$customer[1]="Rahim";
$customer[2]="Karim";
?>
প্রথমে আমরা যে উদাহরণগুলো দিয়েছিলাম সেগুলোতে আমরা কোন নিউমেরিক ইনডেক্স ব্যবহার করি নি। আপনাদের মনে রাখতে হবে যে যখন আমরা কোন অ্যারেকে ডিফাইন করব না তখন সেটি নিজে নিজে নিউমেরিক অ্যারে হিসেবে ডিফাইন হয়ে যাবে।

এসোসিয়েটিভ অ্যারে যে অ্যারেতে ইনডেক্স এবং ডাটা একে অপরের সাথে সম্পর্কযুক্ত হবে তাকে এসোসিয়েটিভ অ্যারে বলে। এসোসিয়েতিভ অ্যারের প্রতিটি ইনডেক্সকে একেকটি কী হিসেবে ধরা হয় এবং প্রত্যেকটা কীর একটা নির্দিষ্ট ডাটা থাকবে। নিচের উদাহরণটিই দেখুন।


<?php
$customer=array("customer_1"=>"Sharif","customer_2"=>"Rahim","customer_3"=>2);
echo $customer[custome_2];
?>
কোডটি সেভ করে রান কিরুন। এখন যেমন ধরুন আপনি নিউমেরিকেলি লিখলেন যে echo $customer[0]
এটি রান করলে সঠিক ফলাফল আসবে না কারন আপনি এখানে এসোসিয়েটিভ অ্যারে ব্যবহার করেছেন। 

মাল্টি ডাইমেনশনাল অ্যারে আমরা এতক্ষন যে অ্যারেগুলো দেখেছি তাদেরকে বলা হয় ওয়ান ডাইমেনসনাল অ্যারে। যখন একটি অ্যারের ভিতর আমরা আরেকটি অ্যারে ব্যবহার করব তখন আমরা তাকে মাল্টি ডাইমেনশনাল অ্যারে বলব। মাল্টি ডাইমেনসনাল অ্যারে বুঝতে হলে নিচের উদাহরণটি দেখুন।

<?php
$customer=array("Sharif","Rahim", array("Karim"));
echo $customer[1];
?>
এই কোডটি রান করালে আপনারা দেখতে পাবেন Rahim কিন্তু আপনি যখন echo $customer[2] দিবেন তাহলে কি হবে। প্রশ্নটি আপনার জন্য রেখে দিলাম। এটা একটা মাল্টিডাইমেনসনাল অ্যারে তাই আপনি এভাবে লিখলে সঠিক রেসাল্ট পাবেন না। আপনাকে লিখতে হবে নিচের মত করে
<?php  echo $customer[2][1];  ?>
এভাবে লিখলেই আপনি কাঙ্ক্ষিত রেসাল্ট পেয়ে যাবেন।

Step by step PHP video tutorials from start to finish: part-2

Previous Video                                       Next Video

Hi friends, this is our second video tutorial on PHP. I hope you enjoyed our first PHP video tutorial. Today I will discuss some important think related with PHP web development with videos.

In this PHP video tutorial you will learn
  • How php echo and print function works. 
  • How to embed PHP inside HTML code.
  • PHP comments writing rules. 
  • How to report error with PHP and 
  • PHP variable, how to declare PHP variable, PHP variable naming convention
Here is the link of our video tutorials. To watch or download each video tutorial just click skip add.

                   Previous Video        Next Video

Membuat Script PHP untuk Kompresi File ZIP


Dengan PHP, kita bisa membuat aplikasi sederhana untuk kompresi file ke dalam bentuk ZIP.

Mengapa kita harus bisa membuat script untuk kompresi file ini, toh di hampir setiap komputer sudah ada software kompresi, meskipun hasil crack-crack an  . Untuk menjawab ini, saya ambil contoh penerapannya. Kalau Anda merupakan adsense publisher, maka setiap interval waktu tertentu Anda akan dikirimi file report earning dalam format CSV yang terkompresi dalam bentuk ZIP file. Apakah setiap pegawai Google Adsense melakukan kompresi setiap laporannya dan mengirimkan satu-persatu file report ini ke semua publishernya secara manual via email? Saya yakin tidak… Mekanisme ini dibuat secara otomatis dengan menggunakan program atau script. Nah… ini salah satu contoh saja alasan mengapa kita juga harus bisa membuat aplikasi untuk kompresi file ZIP via web.

Alasan yang lain… misalkan Anda orang yang ‘baik’ dan tidak ingin menggunakan software crack-crack an untuk kompresi, maka Anda bisa membuat sendiri aplikasinya dengan PHP

Pada tutorial ini akan dibahas bagaimana cara membuat script PHP untuk melakukan kompresi file ZIP. Skenario untuk studi kasus yang diambil di sini adalah: user nantinya akan memilih file yang akan dikompresi melalui form, setelah itu ia mengklik tombol submit, dan hasilnya akan diperoleh file kompresi ZIP dari file yang dipilih tadi. Simple bukan…


Oya… untuk PHP yang dijalankan di Windows OS, pastikan Anda telah mengaktifkan php_zip.dll di file php.ini. Bagaimana caranya? Caranya adalah buka terlebih dahulu file php.ini, bila Anda menggunakan AppServ caranya klik START > AppServ > Configuration Server > PHP Edit The php.ini Configuration File. Selanjutnya cari baris extension=php_zip.dll. Pastikan tidak ada tanda titik koma (;) di depan baris tersebut. Bila sudah, simpan kembali php.ini, dan restart Apache (Web Server).

Nah… sekarang kita mulai membuatnya.

Pertama-tama kita buat form untuk memilih file yang akan dikompresi.

<form enctype="multipart/form-data" action="kompresi.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
Pilih file yang akan dikompresi <input name="file" type="file" />
<input type="submit" name="submit" value="Submit" />
</form>
Selanjutnya kita buat script kompresi.php nya.

<?php

$namaFile = $_FILES['file']['name'];
$tmpName  = $_FILES['file']['tmp_name'];

$fp      = fopen($tmpName, 'r');
$isiFile = fread($fp, filesize($tmpName));
fclose($fp);

$zip = new ZipArchive();
$fileKompresi = $namaFile.".zip";

$kompresi = $zip->open($fileKompresi, ZIPARCHIVE::CREATE);
if ($kompresi)
{
   $zip->addFromString($namaFile, $isiFile);
   $zip->close();
   echo "Kompresi Sukses";
}
else echo "Kompresi Gagal";
?>
Keterangan:

Baris ke-3 digunakan untuk mendapatkan nama file yang akan dikompresi. Nama file ini nanti akan digunakan untuk memberi nama file hasil kompresi (lihat baris ke-11).
Baris ke-4 digunakan untuk menyimpan temporary file yang akan dikompresi. File temporary ini nantinya akan dibaca isinya (baris ke-6 s/d 8).
Baris ke-10 digunakan untuk membuat obyek ZipArchive.
Baris ke-13 digunakan untuk membuat file kompresi.
Baris ke-14 melakukan pengecekan, bila file kompresi berhasil dibuat maka isi file asli yang dibaca akan dimasukkan ke dalam file kompresi. Sedangkan bila gagal, muncul pesan kegagalan.
Dari contoh ini, Anda bisa kembangkan sendiri bagaimana jika kita ingin mengkompresi beberapa file menjadi satu.

OK… mudah-mudahan info bermanfaat.

Control Structures in PHP: FOR

for loops are the most complex loops in PHP. They behave like their C counterparts. The syntax of a for loop is:
 

for (expr1; expr2; expr3)

statement

The first expression (expr1) is evaluated (executed) once unconditionally at the beginning of the loop.

In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends.

At the end of each iteration, expr3 is evaluated (executed).

Each of the expressions can be empty or contain multiple expressions separated by commas. In expr2, all expressions separated by a comma are evaluated but the result is taken from the last part. expr2 being empty means the loop should be run indefinitely (PHP implicitly considers it as TRUE, like C). This may not be as useless as you might think, since often you'd want to end the loop using a conditional break statement instead of using the for truth expression.

Consider the following examples. All of them display the numbers 1 through 10:

 

<?php

/* example 1 */

for ($i = 1; $i <= 10; $i++) {

echo $i;

}

/* example 2 */

for ($i = 1; ; $i++) {

if ($i > 10) {

break;

}

echo $i;

}


/* example 3 */

$i = 1;

for (; ; ) {

if ($i > 10) {

break;

}

echo $i;

$i++;

}

/* example 4 */

for ($i = 1, $j = 0; $i <= 10; $j += $i, print $i, $i++);

?>

Of course, the first example appears to be the nicest one (or perhaps the fourth), but you may find that being able to use empty expressions in for loops comes in handy in many occasions.

PHP also supports the alternate "colon syntax" for for loops.

 

for (expr1; expr2; expr3):

statement

...

endfor;

Registration Form

<!-- save as registration.php-->

<?php
error_reporting(0);
include("config.php");


$firstName=trim($_POST['txtFirstName']);
$middleName=trim($_POST['txtMiddleName']);
$lastName=trim($_POST['txtLastName']);
$username=trim($_POST['txtUsername']);
$password=trim($_POST['txtPassword']);
$txtReTypePassword=trim($_POST['txtReTypePassword']);
$sex=$_POST['sex'];
$txtPLocation=$_POST['txtPLocation'];
$txtAreaAddress=trim($_POST['txtAreaAddress']);
$txtSTDNo=trim($_POST['txtSTDNo']);
$txtPhoneNo=trim($_POST['txtPhoneNo']);
$txtCountryCode=trim($_POST['txtCountryCode']);
$txtMobileNo=trim($_POST['txtMobileNo']);
$selectState=$_POST['selectState'];
$selectCity=$_POST['selectCity'];
$txtCountry=trim($_POST['txtCountry']);


if(isset($_POST['btnSubmit']) && ($_POST['btnSubmit']=="Register Me"))
{

if(empty($firstName))
{
$strError[] .="<li>Please Enter First Name</li>";
}
if(empty($middleName))
{
$strError[] .="<li>Please Enter Middle Name</li>";
}
if(empty($lastName))
{
$strError[] .="<li>Please Enter Last Name</li>";
}
if(empty($username))
{
$strError[] .="<li>Please Enter Username</li>";
}
if(empty($password))
{
$strError[] .="<li>Please Enter Password</li>";
}
if(empty($txtReTypePassword))
{
$strError[] .="<li>Please Re-Type Password</li>";
}
if(empty($sex))
{
$strError[] .="<li>Please Select Sex</li>";
}
if(empty($txtPLocation))
{
$strError[] .="<li>Please Select Preffered Location</li>";
}
if(empty($txtAreaAddress))
{
$strError[] .="<li>Please Enter Address</li>";
}
if(empty($txtSTDNo))
{
$strError[] .="<li>Please Enter STD Code</li>";
}
if(empty($txtPhoneNo))
{
$strError[] .="<li>Please Enter Phone No</li>";
}
if(empty($txtCountryCode))
{
$strError[] .="<li>Please Enter Country Code</li>";
}
if(empty($txtMobileNo))
{
$strError[] .="<li>Please Enter Mobile No</li>";
}
if(empty($selectState))
{
$strError[] .="<li>Please Select State</li>";
}
if(empty($selectCity))
{
$strError[] .="<li>Please Select City</li>";
}
if(empty($txtCountry))
{
$strError[] .="<li>Please Enter Country</li>";
}
if($password != $txtReTypePassword)
{
$strError[] .="<li>Password is not matched</li>";
}
if(!empty($firstName) && !empty($middleName) && !empty($lastName) && !empty($username) && !empty($password) && !empty($txtReTypePassword) && !empty($sex) && !empty($txtPLocation) && !empty($txtAreaAddress) && !empty($txtSTDNo) && !empty($txtPhoneNo) && !empty($txtCountryCode) && !empty($txtMobileNo) && !empty($selectState) && !empty($selectCity) && !empty($txtCountry))
   {
$mysqlSelect = "SELECT * FROM tbl_admin WHERE username='".$username."'";
$mysqlSelected = mysql_query($mysqlSelect);

$count = mysql_num_rows($mysqlSelected);

if($count > 0)
{
$strError[] .= "<li> Username is already exist </li>";
}
else if($password == $txtReTypePassword)
{
$encodedPassword=base64_encode($password);
$txtPrefLocation=implode(",",$txtPLocation);

$mysqlInsertRUser = "INSERT INTO registered_user
(
firstname,
middlename,
lastname,
username,
password,
sex,
preflocation,
address,
stdcode,
phoneno,
countrycode,
mobileno,
state_id,
city_id,
country
)
VALUES
(
'".addslashes($firstName)."',
'".addslashes($middleName)."',
'".addslashes($lastName)."',
'".addslashes($username)."',
'".$encodedPassword."',
'".$sex."',
'".$txtPrefLocation."',
'".addslashes($txtAreaAddress)."',
'".addslashes($txtSTDNo)."',
'".addslashes($txtPhoneNo)."',
'".addslashes($txtCountryCode)."',
'".addslashes($txtMobileNo)."',
'".$selectState."',
'".$selectCity."',
'".addslashes($txtCountry)."'
)";

$mysqlInsertedRUser = mysql_query($mysqlInsertRUser);

$mysqlInsertAdmin = "INSERT INTO tbl_admin
(
username,
password
)
VALUES
(
'".addslashes($username)."',
'".$encodedPassword."'
)";

$mysqlInsertedAdmin = mysql_query($mysqlInsertAdmin);

header('Location: registered.php');
}
}
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registration Form</title>
<link type="text/css" href="css/style.css" rel="stylesheet" />
</head>
<body>
<div id="regiheading">Registration Form
</div>
<div id="regiwrap" align="center">
<table width="620px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="regileftcorntop">
</td>
<td id="regiupperstrip">
</td>
<td id="regirightcorntop">
</td>
</tr>
<tr>
<td colspan="3">
<form name="registrationFrm" action="" method="post" id="registrationID" enctype="multipart/form-data" target="">
<div align="center">
<table border="0" width="620" cellspacing="0" cellpadding="5" align="center">
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td colspan="2" style="color:#FF0000; padding-left:100px;">
<?php foreach($strError as $key => $val)
 {  
echo $val;

 } 
?>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">First Name : 
</td>
<td id="namefields"><input type="text" name="txtFirstName" id="txtFirstNameId" value="<?php echo $firstName; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Middle Name : 
</td>
<td id="namefields"><input type="text" name="txtMiddleName" id="txtMiddleNameId" value="<?php echo $middleName; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Last Name : 
</td>
<td id="namefields"><input type="text" name="txtLastName" id="txtLastNameId" value="<?php echo $lastName; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Username : 
</td>
<td id="namefields"><input type="text" name="txtUsername" id="txtUsernameId" value="<?php echo $username; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Password : 
</td>
<td id="namefields"><input type="password" name="txtPassword" id="txtPasswordId" value="" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Re-Type Password : 
</td>
<td id="namefields"><input type="password" name="txtReTypePassword" id="txtReTypePasswordId" value="" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Gender : 
</td>
<td id="namefields"><input type="radio" name="sex" id="sexId" value="Male" <?php if($sex=='Male') echo 'checked'; ?>/>Male<span><input type="radio" name="sex" id="sexId" value="Female" <?php if($sex=='Female') echo 'checked'; ?>/>Female</span>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Prefferd Location : 
</td>
<td id="namefields"><input type="checkbox" name="txtPLocation[]" id="txtPLocationId" value="Sydney" <?php if($txtPLocation[0]=="Sydney" || $txtPLocation[1]=="Sydney" || $txtPLocation[1]=="Sydney") echo 'checked'; ?>>Sydney<span><input type="checkbox" name="txtPLocation[]" id="txtPLocationId" value="Ottawa" <?php if($txtPLocation[0]=="Ottawa" || $txtPLocation[1]=="Ottawa" || $txtPLocation[2]=="Ottawa") echo 'checked'; ?>>Ottawa</span><span><input type="checkbox" name="txtPLocation[]" id="txtPLocationId" value="Singapore" <?php if($txtPLocation[0]=="Singapore" || $txtPLocation[1]=="Singapore" || $txtPLocation[2]=="Singapore") echo 'checked' ; ?>>Singapore</span>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Address : 
</td>
<td id="namefields"><textarea cols="27" rows="5" name="txtAreaAddress" wrap=yes id="txtAreaAddressID"><?php echo $txtAreaAddress; ?></textarea>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Phone Number : 
</td>
<td id="namefields"><input type="text" name="txtSTDNo" id="txtSTDNoId" size="4" value="<?php echo $_POST['txtSTDNo'] ?>" />-<input type="text" name="txtPhoneNo" id="txtPhoneNoId" size="26" value="<?php echo $_POST['txtPhoneNo'] ?>" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td style="font-size:12px;">STD Code<span style="margin-left:50px;">Phone Number</span>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Mobile Number : 
</td>
<td id="namefields"><input type="text" name="txtCountryCode" value="+91" size="4"  maxlength="3" />-<input type="text" name="txtMobileNo" id="txtMobileNoId" size="26" value="<?php echo $_POST['txtMobileNo'] ?>" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">State : 
</td>
<td id="namefields"><select name="selectState" style="width:239px;">
<option value="0">--- Select State ---</option>
<?php
$state=mysql_query("select * from tbl_state");
while($data=mysql_fetch_array($state))
{
$state_id=$data['state_id'];
$state_name=$data['state_name'];
?>
<option value="<?Php echo $state_id; ?>" <?php if($_POST['selectState']==$state_id)echo 'selected'?>><?Php echo $state_name; ?>
</option>
<?php } ?>
</select>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">City : 
</td>
<td id="namefields"><select name="selectCity" style="width:239px;">
<option value="0">---- Select City ----</option>
<?php
$city=mysql_query("select * from tbl_city");
while($data=mysql_fetch_array($city))
{
$city_id=$data['city_id'];
$city_name=$data['city_name'];
?>
<option value="<?Php echo $city_id; ?>" <?php if($_POST['selectCity']==$city_id) echo 'selected'?>><?Php echo $city_name; ?>
</option>
<?php } ?>
</select>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Country : 
</td>
<td id="namefields"><input type="text" name="txtCountry" id="txtCountryId" size="35" value="<?php echo $_POST['txtCountry'] ?>" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">
</td>
<td id="namefields"><input type="submit" name="btnSubmit" value="Register Me" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td>
</td>
<td id="sideborder">
</td>
</tr>
</table>
</div>
</form>
</tr>
<tr>
<td id="regileftcornbot">
</td>
<td id="regilowerstrip">
</td>
<td id="regirightcornbot">
</td>
</tr>
</table>
</div>
</body>
</html>