Latest Posts

Friday, 26 March 2010

The text editor for the website

You must have seen sites that provide facilities to fill in a text editor or news messages.For that you are biased using FCKeditor text editor which you can get on the site http://www.fckeditor.net how to use it is as follows :

1.Make sure you have uploaded FCKeditor folder on the server hosting,
But for a while you use the localhost server.Open the web browser and type the address www: / / localhost/filephp/fckeditor/_sample/php/sample01.php


2.If the process is successful, it will display the page with your browser text editor
3.After that use a text editor to stay on top.Then click the submit button to get the html editor



read more...

Thursday, 25 March 2010

Restrict file uploads allowed

In matters of uploaded files,usually the size of the file has been limited by the server.We can take a look at the php.ini file or via php post_max_size info for section.

form_upload.php

<form enctype="multipart/form-data" method="post" action="upload.php">
File yang diupload : <input type="file" name="fupload"><br>
<input type=submit value=Upload></form>


upload.php
<?php
$lokasi_file = $_FILES['fupload']['tmp_name'];
$nama_file = $_FILES['fupload']['name'];
$ukuran_file = $_FILES['fupload']['size'];
/ / If the file size> maximum size of the file
if ($file_size > $_POST[size_maks_file]){
echo "Upload Gagal !!! <br>
file size <b>$file_name</b> : $file_size bytes<br>
file size should not be > 1000000 bytes (1 Mb) <br>";
}else{
$directory_file = "files/$file_name";
move_uploaded_file($file_location,"$directory_file");
echo "File name : <b>$file_name</b> successfully uploads <br>";
echo "File size : <b>$file_size</b> bytes";

/ / Insert the file information into the database
mysql_connect("localhost","root","pajarmaning");
mysql_select_db("pintar");$input="INSERT INTO upload_file(file_name,file_size,description,directory)
VALUES('$file_name','$file_size','$description','$dirctoryi')";
mysql_query($input);
}?>


first run form_upload.php, click search to find the right files in the uplaod then click upload

read more...

Wednesday, 24 March 2010

Mulitple File Upload

In some applications such as file attachments in Yahoo email or upload files in Cpanel server hosting,we can immediately upload multiple files at once.For that we can use arrays and loops.

Make a table in advance to accommodate the information from the uploaded file.

Field

Type

Length

Extra

Primary

Id_upload

Int

3

Auto_increment

yes

Nama_file

Varchar

100



Ukuran

int

100



Deskripsi

text




Direktori

varcahr

100




Then bolts unutk accommodate special folder the files that you upload.such as folders files the folder should be placed in the folder where you saved the web.

Script form_uploadesfiles.php

<FORM ENCTYPE="MULTIPART/FORM-DATA" ACTION="uploadfiles.php" METHOD="POST">

File 1: <INPUT TYPE="FILE" NAME="fupload[]"><BR>

File 2: <INPUT TYPE="FILE" NAME="fupload[]"><BR>

File 3: <INPUT TYPE="FILE" NAME="fupload[]"><BR>

File 4: <INPUT TYPE="FILE" NAME="fupload[]"><BR>

File 5: <INPUT TYPE="FILE" NAME="fupload[]"><BR>

< INPUT TYPE="SUBMIT" VALUE="Upload"> </FORM>



Script uploadesfiles.php

<?php
$lokasi_file = $_FILES['fupload']['tmp_name'];
$nama_file = $_FILES['fupload']['name'];
$ukuran_file = $_FILES['fupload']['size'];

echo "File-file yang berhasil diupload: <BR><BR>";

/ / Calculate the number of uploaded files

$jml_file=count($nama_file);
$i=0;

/ / Do the repetitions for $ i <= number of uploaded files
while ($i < $jml_file)
{
if ($nama_file[$i] != ""){
$direktori = "files/$nama_file[$i]";
move_uploaded_file($lokasi_file[$i],"$direktori");
echo "<B>$nama_file[$i]</B><BR>";

/ / Insert the file information into the database

mysql_connect("localhost","root","pajarmaning");
mysql_select_db("pintar");
$input="INSERT INTO upload_file(nama_file,ukuran_file,deskripsi,direktori)
VALUES('$nama_file[$i]','$ukuran_file[$i]','$_POST[deskripsi]','$direktori')";
mysql_query($input);
}
$i++;
}
?>

First of all, run the script form_uploadesfiles.php,then click the button five Browse.lalu find the file you upload, and press the upload button




read more...

Friday, 19 March 2010

Print Page

1.Create a php file, then type the code below.

<?php
echo '<font face="Verdana" size="6">
Contoh untuk cetek halaman dengan </font>
<font face="Verdana" size="6" color="#FF0000">PHP</font><br>';
echo '<font face="Verdana" size="2">
/ / create a link to call the print dialog box that is on the browser
<A HREF="javascript:window.print()">
Klik di sini </A>untuk mencetak halaman</font>';
?>


2.
Save on a web server with the name cetak_halaman.php
3.
open the web browser and typing the address link http:localhost/cetak_halaman.php
4.
clikklik_disini to print this page



read more...

Thursday, 18 March 2010

pagging google style

In this trick we show only three digits if they are on the first page ,the second and last page.eg 123 ... 8.And five-digit paging to another page (two numbers before and after the current page) such as the current page is page 3 , then the pagingnya 12,345 ... 9.So what changed only on the page displaying bagain numbers only.

1.Create table
CREATE TABLE `anggota` (
`id_ang` int(3) NOT NULL auto_increment,
`nama` varchar(50) collate latin1_general_ci NOT NULL,
`alamat` varchar(100) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id_ang`)


2.Script Pagging

$no$data[nama]$data[alamat]"; $no++; } echo "
"; $file="paging_6.php";">paging.php

mysql_connect("localhost","root","root");
mysql_select_db("pintar");

/ / Step 1

$batas=5;
$halaman=$_GET['halaman'];
if(empty($halaman))
{
$posisi=0;
$halaman=1;
}
else
{
$posisi = ($halaman-1) * $batas;
}

//Step 2

$no$data[nama]$data[alamat]"; $no++; } echo "
"; $file="paging_6.php";">$tampil="select * from anggota limit $posisi,$batas";
$hasil=mysql_query($tampil);

$no=$posisi+1;
while ($data=mysql_fetch_array($hasil)){
echo "$no$data[nama]$data[alamat]";
$no++;
}
echo "
";

$file="paging.php";

//Step 3

$tampil2="select * from anggota";
$hasil2=mysql_query($tampil2);
$jmldata=mysql_num_rows($hasil2);

$jmlhalaman=ceil($jmldata/$batas);

/ / link to the previous page (previous)
1) { $previous=$halaman-1; echo "<<> | <> | "; } else { echo "<<>if($halaman > 1)
{
$previous=$halaman-1;
echo "
<<> |
<> | ";
}
else
{
echo "<< First | < Previous | ";
}

/ / display link .. 123 pages google-style modification
/ / initial number

3 ? " ... " : " "); for($i=$halaman-2;$i<$halaman;$i++) { if ($i < href="$file?halaman="$i">$i
"; }">$angka=($halaman > 3 ? " ... " : " ");
for($i=$halaman-2;$i<$halaman;$i++)
{
if ($i < 1)
continue;
$angka .= "$i ";
}
/ / number was
$halaman "; for($i=$halaman+1;$i<($halaman+3);$i++) { if ($i > $jmlhalaman) break; $angka .= "$i "; }">$angka .= " $halaman ";
for($i=$halaman+1;$i<($halaman+3);$i++)
{
if ($i > $jmlhalaman)
break;
$angka .= "$i ";
}

/ / number end
$jmlhalaman " : " ");">$angka .= ($halaman+2<$jmlhalaman ? " ...
$jmlhalaman " : " ");

/ / print all the numbers
echo "$angka";
/ / next view the first link (Next)
Next > | Last >> "; } else { echo " | Next > | Last >>"; } echo "

Total anggota : $jmldata orang

"; ?>">if($halaman < $jmlhalaman)
{
$next=$halaman+1;
echo " | Next > |
Last >> ";
}
else
{
echo " | Next > | Last >>";
}
echo "

Total anggota : $jmldata orang

";

?>



read more...