jump to navigation

How to make a blog site February 4, 2010

Posted by Shamim Ahmed in Php.
add a comment

Suppose you need a blog site where you want to add a new page like  wordpress then you need to follow the following tips.

All are same like my previous tutorial but we will use database.. all information will retrive from database. suppose database name is shamim and a table named by pages with three fields like as page_id, page_title, and page_desc

then   …………………………………include.php…………………………….

<?php

//connect to db
mysql_connect(“localhost”, “root”, “”)or die(“Cannot connect to the Database Server”);
mysql_select_db(“shamim”)or die(“Cannot select Database”);

?>

<head>
<title>My Tutorial</title>
<link href=”style.css” rel=”stylesheet” type=”text/css” />
</head>

<body>
<table width=”700″ border=”1″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td><?php include(“header.php”); ?></td>
</tr>
<tr>
<td><?php
//all pages will include here

if(isset($_GET['s'])) {    $includepage=$_GET['s'];}
else{$includepage    =    1;}

switch($includepage)    {

case “”:
include(“start.php”);
break;

case 1:
include(“start.php”);
break;

case 2:
include(“pages.php”);
break;

case 3:
include(“add_pages.php”);
break;

default:
include(“start.php”);
break;
}

?></td>
</tr>
<tr>
<td><?php include(“footer.php”); ?></td>
</tr>
</table>

</body>
</html>

…………………………pages.php…………………………………

<?php
$page_id    =    $_GET['page_id'];
$q    =    mysql_query(“SELECT * FROM pages WHERE page_id=$page_id”);
while($r=mysql_fetch_array($q))
{
echo “<h2>”.$r['page_title'].”</h2>”.nl2br($r['page_desc']);
}

?>

………………………………… add_page.php………………………….

<h2>Add Pages </h2>
<?php
if(isset($_POST['Submit']))
{
$page_title    =    $_POST['page_title'];
$page_desc    =    $_POST['page_desc'];

$q    =    mysql_query(“INSERT INTO pages(page_title,page_desc) VALUES(‘$page_title’,'$page_desc’)”);
if($q){echo “Added”;}else{echo “Sorry”;}
}

?>

<form name=”form1″ method=”post” action=”">
<table width=”400″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td>Page Title</td>
<td><input name=”page_title” type=”text” id=”page_title”></td>
</tr>
<tr>
<td>Page Details </td>
<td><textarea name=”page_desc” id=”page_desc”></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type=”submit” name=”Submit” value=”Submit”></td>
</tr>
</table>
</form>

…………………………header.php……………………………….

<h1 align=center>Shamim</h1>
<a href=”./”>Home</a>
<a href=”index.php?s=3″>Add Pages</a>
<?php

$q    =    mysql_query(“SELECT page_id,page_title FROM pages”);
while($r=mysql_fetch_array($q))
{
echo “<a href=index.php?s=2&page_id=”.$r['page_id'].”>”.$r['page_title'].”</a>&nbsp;&nbsp;”;
}
?>
……………………………..  footer.php…………………………….

&copy; 2010. Shamim.com

…………………….start.php…………………

<h2>Welcome</h2>

…………………………style.css………………………

body
{
font-family: Arial;
}

h1
{
color: #ff0000;
}

h2
{
color: #0000FF;
padding: 5px 0 5px 5px;
margin: 0;
}

a
{
color: #00FF00;
text-decoration: none;
}

a:hover
{
color: #ff0000;
}

…………………………………………………………………………………………………….

sorry i couldn’t write details for unsufficient time.. I will try to details i just paste code from editor if you face any problem then mail me thanks now start to do it..

How to change content without loading the page in php February 4, 2010

Posted by Shamim Ahmed in Php.
add a comment

It is very important to build a simple website.. and It is nice to look. and it reduce the time complexity to load a page.

Suppose we want to build a website where header, footer, sidebar all will be fix but only page body( content-discription)  will be changed then you need to follow the following tips.

suppose your website is very simple look like as below

Here there is only three part of website just for tutorial at the top of the table is header and last part of table is  footer which will not be changed . and at the midle part of  the table we will include all page here.

then

…………………….index.php……………………

<body>
<table width=”700″ border=”1″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td><?php include(“header.php”); ?></td>   //fix in the first table
</tr>
<tr>
<td>
<?php                                                  // positioning in the middle table
//all pages will include here

if(isset($_GET['s'])) {   $includepage=$_GET['s'];}
else{$includepage  =  1; }

switch($includepage)    {

case ” “:
include(“start.php”);
break;

case 1:
include(“start.php”);
break;

case 2:
include(“about.php”);
break;

case 3:
include(“contact.php”);
break;

default:
include(“start.php”);
break;
}
?>
</td>
</tr>
<tr>
<td><?php include(“footer.php”); ?></td>  // fix in the last table
</tr>
</table>

</body>

……………about.php………………..

<h2>About me</h2>
My name is hamim<br />
I live Rajshahi

………………… contact.php………………

<h2>Contact us</h2>
mail me

…………………header.php……………………

<h1 align=center>Shamim</h1>
<a href=”./”>Home</a>
<a href=”index.php?s=2″>About us</a>
<a href=”index.php?s=3″>Contact us</a>

…………………footer.php……………….

&copy; 2010. Shamim.com

…………………..start.php………………….

<h2>Welcome</h2>

………………….Style.css………………….

body
{
font-family: Arial;
}

h1
{
color: #ff0000;
}

h2
{
color: #0000FF;
padding: 5px 0 5px 5px;
margin: 0;
}

a
{
color: #00FF00;
text-decoration: none;
}

a:hover
{
color: #ff0000;
}

………………………………………………………………………………………………………..

yes done now you can start.. to customizing your own site..

How to show data from database in php January 31, 2010

Posted by Shamim Ahmed in Php.
add a comment

//……………………….show.php…………………………..\\

<table>
<tr>
<td align=”center”>EDIT DATA</td>
</tr>
<tr>
<td>
<table border=”1″>
<?
$con = mysql_connect(“localhost”,”",”");
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}

mysql_select_db(“naogaon”, $con);
$order = “SELECT * FROM member”;
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
echo (“<tr><td>$row[number]</td>”);
echo (“<td>$row[name]</td>”);
echo (“<td>$row[address]</td>”);
echo (“<td><a href=\”edit_form.php?id=$row[employees_number]\”>Edit</a></td></tr>”);
}
?>
</table>
</td>
</tr>
</table>

output:

Inserting Data in php MySQL database. January 31, 2010

Posted by Shamim Ahmed in Php.
add a comment

To inserting a data to database you have to create a database and a table in going to http://localhost/phpmyadmin..

suppose your database name is naogaon and table name is member with three fields number, name and address

then write the following code in a editor and save it as

//……………………insert.html……………………….\\

<form action=”Insert.php” method=”post”>
Number: <input type=”text” name=”M_number” />
Name: <input type=”text” name=”M_name” />
Address: <input type=”text” name=”M_address” />
<input type=”submit” />
</form>

now write another php code and save it as

//…………………insert.php……………………….\\

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

mysql_select_db(“naogaon”, $con);

$sql=”INSERT INTO member (number, name, address)
VALUES
(‘$_POST[M_number]‘,’$_POST[M_name]‘,’$_POST[M_address]‘)”;

if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}
echo “1 record added”;

mysql_close($con)
?>

How to Display Data from Database to selectbox January 31, 2010

Posted by Shamim Ahmed in Php.
add a comment

It is very easy. At first you have to insert some data to your database suppose its database name is naogaon and table name is member and there is colum name by number then.. write the following code and save you as your like.. ok done check it.

//    …………………Selectbox.php…………………….\\

<?php
$con = mysql_connect(“localhost”,”",”");
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“naogaon”, $con);
$query = “SELECT number FROM member order by number “;

$result = mysql_query($query) or die(“Couldnt execute query.”);

echo ‘<select name=”number” id=”number”>’;
while($row = mysql_fetch_array($result))
{
$val = $row['number'];
echo “<option value=$val>$val</option>”;
}
echo ‘</select>’;

?>

 

How to upload a image in MySQL database in php January 22, 2010

Posted by Shamim Ahmed in Php.
add a comment

here I just tested the code.. at first you need to create a database and create a table with two field named by “fileloc” and “id” and also create a folder “pic” in apache htdocs.

then save the following code as    upload.html………..

<form action=”upload.php” method=”post”
enctype=”multipart/form-data”>
<label for=”file”>Upload a picture:</label>
<p>
<input type=”file” name=”file”  />
</p>
<p><br />
Enter id
<input name=”id” type=”text”>
</p>
<p>
<input type=”submit” name=”submit” value=”Submit” />
</p>
</form>

after saving this open a new window and write the following code and save as upload.php

<?php
if ((($_FILES["file"]["type"] == “image/gif”)
|| ($_FILES["file"]["type"] == “image/jpeg”)
|| ($_FILES["file"]["type"] == “image/pjpeg”))
&& ($_FILES["file"]["size"] < 400000))
{
if ($_FILES["file"]["error"] > 0)
{
echo “Return Code: ” . $_FILES["file"]["error"] . “<br />”;
}
else
{
echo “Upload: ” . $_FILES["file"]["name"] . “<br />”;

if (file_exists(“pic/” . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . ” already exists. “;
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],”pic/” . $_FILES["file"]["name"]);
echo “Stored in: ” . “pic/” . $_FILES["file"]["name"];
}
}
}
else
{
echo “Invalid file”;
}

?>

<?php include(“dbconnect.php”);?>

<? $id=$_POST['id'];
$fileloc=”pic”.”/”.$_FILES["file"]["name"];
echo $id;
echo $fileloc;
$query=”INSERT INTO fileupload(id,fileloc) VALUES (‘$id’,'$fileloc’)”;
$d=@mysql_query($query);
if ($d)
echo “Success”;

?>

yaa done ! now try yourself..

How to upload a file in phpMySQL database January 22, 2010

Posted by Shamim Ahmed in Php.
add a comment

It is very easy just at first you have to  create a table in mysql under a database with five fields like as  description, data, filename, filesize, filetype and  write the following code

//…………………………………upload.html…………………………………………………\\

<html>
<body>
<form method=”post” action=”upload1.php” enctype=”multipart/form-data”>
Description:<br>
<input type=”text” name=”form_description” size=”40″>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”1000000″>
<br>File to upload:<br>
<input type=”file” name=”form_data” size=”40″>
<p><input type=”submit” name=”submit” value=”submit”>
</form>
</body>
</html>

then write an another php program like as

//…………………………..upload.php………………………………………………\\

<?php
mysql_connect(“localhost”,”username”,”password”);
mysql_select_db(“database_name”);
$data = addslashes(fread(fopen($form_data, “r”), filesize($form_data)));
$result=MYSQL_QUERY(“INSERT INTO uploads (description, data,filename,filesize,filetype) “. “VALUES (‘$form_description’,'$data’,'$form_data_name’,'$form_data_size’,'$form_data_type’)”);
$id= mysql_insert_id();
print “<p>File ID: <b>$id</b><br>”;
print “<p>File Name: <b>$form_data_name</b><br>”;
print “<p>File Size: <b>$form_data_size</b><br>”;
print “<p>File Type: <b>$form_data_type</b><p>”;
?>

ok done.. you try yourself

Showing Cricket Score to Firefox Status bar January 22, 2010

Posted by Shamim Ahmed in 1.
Tags:
2 comments

Many website are now used to show current cricket Score.. but if you don’t want enter those website and want to know the current score then this way is needed for you.. just go..https://addons.mozilla.org/en-US/firefox/addon/4699 and add a add-ons and then restart the firefox… yaaa it is done and enjoy..

ফায়ারফক্সের গতি বাড়ান খুবই সহজে January 21, 2010

Posted by Shamim Ahmed in 1.
Tags:
add a comment

কিভাবে করতে হবে

১) এড্রেস বারে লিখুন about:config

২)স্ক্রল করে খুজে বের করুন এই এন্ট্রিগুলো

network.http.pipelining

network.http.proxy.pipelining network.http.pipelining.maxrequests

এইবার প্রথম এবং দ্বিতীয় টিকে true করে দিন তৃতীয়টির নাম্বার ভ্যালু সেট করে দিন 30

3) অবশেষে রাইট বাটনে ক্লিক করে নতুন একটি integer নিন নাম দিন nglayout.initialpaint.delay এটার ভ্যালু সেট করে দিন 0 ব্যাস হয়ে গেল

এবার দেখুন আপনার ফায়ারফক্সের গতি কেমন বেড়েছে।

রাজশাহী হবে আইটি নগরী। January 8, 2010

Posted by Shamim Ahmed in 1.
add a comment

অনেক দিন থেকেই একটা  ভাবণা আমাকে  প্রায় ভাবাতো বিষয়টা ছিল ঠিক এমন,  রাজশাহীতে তো কোন কলকারখানা গড়ে ওঠেনি, এখানে এখনও গ্যাস পাইপলাইন আসেনি। আগামী ১০ বছরে এখানে তেমন কিছু হবে এইটা চিন্তা করাও অনেক কঠিন। তাহলে রাজশাহী বাসীর ভবিষ্যত কী ?

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

স্যার ‘এর পরামর্শেই আমরা কয়েকজন রাজশাহীতে আইটি নগরী গড়ে তোলা সম্ভব কিনা এই নিয়ে একটি জরিপ করছিলাম।।

প্রথমেই আমরা জরিপ করি রাজশাহীর কিছু উন্নয়নকর্মী যারা রাজশাহীর জন্য কিছু করার চেষ্ঠা করে। তাদের মধ্যে একজন জামাত খান,

জামাত খান সাহেব বিষয়টি জেনে অত্যন্ত খুশি, তারা নিজেরাও এমনটি ভাবেন, তিনি জানেন রাজশাহীতে আইটি নগরী গড়ে তোলা কত বেশী গুরুত্তপুর্ন একটা দাবী, তিনি বলেছেন, তার অবস্থান থেকে তিনি আইটি নগরী গড়ে তুলতে সর্বোচ্চ সহযোগিতা করবেন এবং আমাদের সাথে তিনিও এই বিষয়ে কাজ করবেন। তার মাধ্যমেই পরিচয় হয়, রাজশাহীর স্থানীয় সংবাদ পত্র সোনালী সংবাদের সম্পাদক মোঃ লিয়াকত আলী সাহেবের সাথে, তিনি ও আমাদেরকে বেশ সহযোগিতা দিয়েছেন, সেই সাথে বলেন, বিসিক এলাকায় অনেক জায়গা আছে, সেখানে আমরা সহজেই আইটি নগরীর জন্য একটা অবকাঠামো দাড় করাতে পারি।

তারপর জামাত খান সাহেবের পরামর্শেই আমরা রাজশাহী চেম্বার অব কমার্চ ইন্ডাট্রির প্রেসিডেন্ট এবং ডিরেক্টর দের সাথে একসাথে বসে এ বিষয়ে অনেক আলাপ করি,  তারা আইটি নগরীর প্রয়োজনীতা জানেন এবং বাঙ্গালোর ভিজিট করেছেন, তারা দেখেছেন বাঙ্গালোর এর বাস্তব অবস্থা, তারা রাজশাহীতে ও এমন সপ্ন দেখেন, এই প্রজেক্টকে সফল করতে তারা আমাদেরকে সর্বোচ্চ সহযোগিতা করবেন, প্রয়োজনে তারা এই বিষয়ে চেম্বার অব কমার্চ থেকে প্রধানমন্ত্রী পর্যন্ত আবেদন করবেন।

এবং রাজশাহীতে আইটি নগরী  বিষয়ে যদি কোন সমাবেশ হয় তাহলে তারা পুরো ইস্পন্সর দিবেন।

এরপরই আমারা বসি জাতীয় সংসদের সদস্য জনাব ফজলে হোসেন বাদশা’এর সাথে, তিনি আমাদের’কে আরও বেশ কিছু গুরুত্তপুর্ন তথ্য দিয়েছেন, তিনি বলেছেন এই বিষয়ে তিনি সংসদে  মন্ত্রীকে প্রশ্ন করলে মন্ত্রী নিজেও সংসদে রাজশাহীতে আইটি নগরী গড়ে তোলার ঘোষনা দিয়েছেন। তিনি আমাদেরকে পরামর্শ দিয়েছেন এই বিষয়ে মন্ত্রীর সাথে কথা বলতে, এবং তিনি নিজেও মন্ত্রীর সাথে কথা বলবেন এ বাপারে মন্ত্রালয়ে অনেক পেপার তৈরী করা আছে।

এই তথ্য গুলো পেয়ে আমরা আরো সাহসী হয়ে উঠি, এর পরপরই আমরা আরও কিছু গুরুত্তপুর্ন মানুষের সাথে কথা হয়, বিশেষ করে যাদের কথা না উল্লেখ করলেই নয় এমন দুইজন ব্যাক্তি প্রফেসর  ডঃ মোঃ মুর্তুজা আলী স্যার ( রেজিষ্টার, রাজশাহী প্রকৌশল ও প্রযুক্তি বিশ্ববিদ্দ্যালয় ) এবং রাজশাহী বিশ্ববিদ্দ্যালয়ের কম্পিউটার কৌশল বিভাগের চেয়ারম্যান ডঃ শামীম আহমেদ স্যার এর সাথে যাদের অনুপ্রেরনা আমাদেরকে আরও একধাপ এগিয়ে দেয়। তারপর আমরা রাজশাহীর সব সফটওয়ার ফার্মের মালিক এবং কিছু আউটসোর্সিং করে এমন মানুষ দের সাথে একসাথে বসি। যেখানে আমাদের অনুরোধে মুনীর হাসান স্যার ও উপস্থিত থাকেন। স্যার এর সুচিন্তিত মতামতে আমরা আরো ব্যাপক ভাবে কাজ শুরুর কথা ভাবি।

ভাবনা গুলো ছিলো এমন।

বিশেষ করে প্রথমেই রাজশাহীতে  নগরীর মত করে পরিবেশ  তৈরী। এখানে তিনটা এলাকাকে (রাবি, রুয়েট, সাহেব বাজার)  ওয়াই ফাই নেটওয়ার্ক করা যেতে পারে।

তাছাড়া একটা ওয়েব সাইট করা হবে যেখানে আমরা কি কি করছি এবং আমাদের কি কি আছে, আমরা কেনো রাজশাহীতে আইটি নগরী গড়ে তোলতে চাই এসব বিষয় নিয়মিত আপডেট করা হবে। তারপর আমরা এখন একটা লিস্ট করছি যেখানে আইটি নগরী গড়ে তুলতে রাজশাহীতে কি আছে  আর কি নাই এসব থাকবে। …

আশা করছি আমরা ঠিক পথেই এগিয়ে যাচ্ছি। তারপরও যদি কারও পরামর্শ থাকে জানতে পারলে অনেক ভালো হত।