Category Archives: PHP

Image Processing On Web. Is It Possible ?

Some people might think that we can’t process image through web, just because limited resources and also limited library to process it. Even though it is possible to do with traditional way, the programmer must process the image just like complicated image processing in ussual. This is also happened to me, because several weeks ago my lecturer asked me to make web image processing. He said that “You had to implement image function on the web. at least it must be like web design for designing something like cloth, t- shirt, or jacket”. I was so confused at the time, but on the other case, i also become proud of my self. Because if i am capable  to make it, means that  i can make something new for my study journey.

Day by day, i look for the related resources. And in the end, i found GD library on php.net like php it self, GD library is open source as free to use and free to distribute. But, GD library it self only focus on “how to process image by calibrating with PHP “. There are so many functions that we can use ing GD library. For example, water marking, create PNG file/ Create another image files.

Based on my brief learning, i got an idea and understand about it at the last day of the “dead line”. So, i made the web only in one night. Simply, if we already installed Xampp on Windows or Lampp on Linux, means that we already installed GD functions on it. We can check it by using function “phpinfo();”  if GD function is enable means that we were ready to make it.

here is the screen shots of my project

i implement several functions from GD Library :

  • rotate
  • resize
  • load
  • gray scale
  • adding label

 

That’s all functions that i use in this project. Even though it is not quiet good. i am still proud of it, because that is my own job only in one night, and the result is, i get the best assessment at the time.

Advertisements

Displaying Guest Book List On Web Browser Using PHP

Two days ago, I’ve just making tutorial about how to make guest book in PHP and how to save it in a single text document. But, in this time I’d like to show how to display all of guest which is already visit the web site on web browser it self. Actually, it is only the continue of file processing chapter in PHP. And , this is a little bit implementation about it.

Alright, here is the source code :


<?php

$namafile="bukutamu.txt";

$fo=fopen($namafile,'r');

while(!feof($fo)){

$baca=fgets($fo,2048);

echo "$baca <br />";

}

?>

The ‘r’ parameter means that the file named “bukutamu.txt” is opened using mode read because I only want to display the content of it.

The Making of Guest Book in Web Application Using PHP

Recently, i have just learned about web programming. Actually, there are several items that we must know to build or create a good website. The first is HTML code, the second one is PHP structure. CSS , javascript, jquery and etc.

Alhamdulillah, only in several days, i already finished them.but, even though i think it is already good enough.

first of all, we have to prepare the form. I mean guest book form. And then make file to process data which is already sent named savefile.php.. and the last task is put the file into guest_log.txt”. Here is the first step.


<html>
<head>
<title>Buku Tamu</title>
<script>
function validasi(){
var nama=form.txtnama.value;
var emailregex=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var email=form.txtemail.value;
if(nama==""){
alert('nama harus diisi');
return false;
}
if(!(email.match(emailregex))){
alert("alamat email tidak valid");
return false;
}
}
</script>
<style>
h1{
background:#FFFFFF;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:40px;
padding-top:18px;
}
</style>
</head>
<body>
<h1 align="center">Selamat Datang</h1>
<table align="center" border="1" cellpadding="20">
<tr>
<td>
<table border="0" cellpadding="5">
<form method="post" action="save.php" name="form" id="form" >
<tr>
<td align="right">Nama :</td><td><input type="text" name="txtnama" id="txtnama" onBlur="return validasi()"/></td>
</tr>
<tr>
<td align="right">Alamat :</td><td><input type="text" name="txtalamat"/></td>
</tr>
<tr>
<td align="right">E- mail :</td><td><input type="text" name="txtemail" onBlur="return validasi()"/></td>
</tr>
<tr>
<td align="right">Website/ Blog :</td><td><input type="text" name="txtblog"/></td>
</tr>
<tr>
<td align="right">Komentar :</td><td><textarea name="txtkomentar"></textarea></td>
</tr>
<tr>
<td align="right"><input type="submit" value="Save" name="btsave" /></td><td><input type="reset" value="Reset"/></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>


alright, if you check out in your browser, the preview is almost like this one,it means that you have been sucessfull to make the form, and the next, is to send the form using method post into file save.php.But, before that, we have to make file bukutamu.txt in the same directory of the program.

here is the code for saving data of guests :

<?php
$nama=$_POST['txtnama'];
$alamat=$_POST['txtalamat'];
$email=$_POST['txtemail'];
$blog=$_POST['txtblog'];
$komentar=$_POST['txtkomentar'];
if(empty($nama)){
echo "nama kosong harus diisi";
}
$simpan="Nama = $nama \n alamat=$alamat \n email=$email \n blog=$blog \n komentar = $komentar \n";
$daftartamu="bukutamu.txt";
if(file_exists($daftartamu)){
echo "file is found";
$fo=fopen($daftartamu,'a');
fputs($fo,$simpan,1024);
fclose($fo);
}
else{
echo "file not found";
}
?

Inside the code above, there are several functions for file operation such as fopen, feof, fgets and etc. that’s why in this program doesn’t need database as storage. here is the result of the program :

good luck 🙂