Archive for the 'PHP' Category

Lagi belajar coding? Ada layanan webhosting (nyaris) gratis untuk Anda

Anda sedang belajar PHP ? Bingung bagaimana cara menampilkannya di Internet ? Osama dong, dulu saya juga mengalami masalah yang sama. Sampai berhari-hari saya mencari provider hosting gratis, dapatnya juga cuma ngasih kapasitas seupil :D

Adik saya malah apes, dia dapat domain name gratis — tapi kemudian disandera oleh mereka. Sampai sekarang domain name yang bagus tersebut masih tetap tidak bisa dia miliki lagi.

Sekarang sudah enak buat Anda sekalian.

Kawan saya, Riyogarta, menawarkan webhosting gratis (1) bagi Anda yang sedang belajar PHP (2)

Fiturnya ?

* Disk Space 2000 MB atau lebih
* Bandwith 18GB/bulan atau lebih
* PHP versi 4/5
* MySQL 5 dengan jumlah database unlimited
* PHPMyAdmin yang sudah terinstall
* Satu account Shell/FTP user
* Empat puluh account email (Webmail/POP3/IMAP) dengan domain yang Anda miliki
* Unlimited subdomain (khusus bagi mereka yang memiliki domain).
* Backup file ( 1 hari sebelumnya, 2 hari sebelumnya, 1 minggu sebelumnya, 2 minggu sebelumnya, 1 bulan sebelumnya, 2 bulan sebelumnya )
* Backup database ( hanya dipergunakan dalam keadaan darurat saja, Saya tidak mau direpotkan dengan permintaan restore dari Anda)
* Mmm, apalagi ya? :-? Cukup sebegitu dulu :D

Keren kan ?

Salut untuk bang Riyo atas inisiatifnya ini. Ini dia tindakan nyata yang dapat membantu banyak kawan-kawan kita.

OK, bagi yang tertarik, silahkan langsung klik disini saja. Enjoy !

(1) Awalnya gratis, namun kemudian setelah mempertimbangkan beberapa hal, termasuk kemungkinan layanan gratis ini di abuse, maka beliau terpaksa memutuskan untuk menarik sedikit biaya. Hanya Rp 15.000 untuk webhosting 2 tahun!

(2) Ada beberapa persyaratan, jadi tidak semuanya bisamendapatkan fasilitas ini. Tapi ini semata-mata untuk menjamin bahwa yang mendapatkan ini betul-betul adalah mereka yang memerlukannya.

PHP : Form Builder / Generator

My work is involving more and more PHP-based forms, so I decided today to find a good form generator to save my time.
Here’s my requirements :

  1. Willing to pay : I’m willing to pay for the right solution.
  2. Easy to use : Some of the script actually make life harder for you, go figure. I was looking to save time, not to spend more of it
  3. Flexible : I still need to apply my own style / formatting. The solution must allow me to do this, while comforming to the second requirement above
  4. Saving to database : some PHP form makers / generators will only allow you to submit the form to be send by email.
  5. Validation : surprisingly, quite a lot of the (even) commercial solutions out there are missing this.
  6. Source available : I need the source code available to me, in case of problems / need for further customizations. Some packages doesn’t give you this.

Too picky ? Well, my needs are quite advanced indeed.
Anyway, I spend almost two hours browsing around with no joy, until suddenly …. to my surprise (again), it seems that the best solution for my needs is an open source one - the HTML_QuickForm PEAR Package.

It’s easy to use (see the tutorial for yourselves).

It’s definitely very flexible; it provides 8 renderers and support several template engines ! It allows you to process the submission however you chooses with the process method - by email, to database, or you can also process it straight away in the same script.

And validations… it’s really sweet. You can choose whether to do it on the server or client side. When you choose to do it on the client, it automatically generate the needed Javascript codes for you. Awesome is not descriptive enough word for it.
There are many ready-to-use validation rules; alphanumeric, lettersonly, maxlength, minlength, etc - and the regex rule fulfill any other needs that’s otherwise not available.

With the source also available, it’s really hard for me to look for anything else. But if you think you’ve found something better, feel free to let me know.

Enjoy.

Cara Mudah Belajar PHP

[ Tutorial-tutorial ini ]ditujukan bagi mereka yang belum tahu mengenai PHP sama sekali.
Namun jangan salah, ada banyak juga materinya yang sangat berguna bagi programmer PHP pemula / menengah.

Selamat membaca !

PHP: ajax without XMLHTTP-request

Got a request to make a quick hack; but this quick hack will be immensely helpful and able to cut like 3 hours of work / employee everyday. Naturally, seeing such huge cost / benefit ratio, I agreed to make it my priority.

The hack is to make pricing become automatic for a client. At the moment, they have to look up a pricing table manually for each order that they received. Even though they’re pretty big, built their own IT system from scratch, they’re still doing this particular topic manually. I can’t believe that their previous developer missed this stuff.

Until I realized the full scope of the job…. suffice to say, it’s complicated enough to scare most programmers. Their pricing scheme almost got no pattern at all, almost fully customized for every client. Yet we can’t afford to just enter the whole thing as it is to the database - it’d be too cumbersome.
The previous developers spent 3 years developing the system, and still managed to avoid this particular bit.

More time would be required to develop the algorithm and proper database schema, than the actual coding itself. Anyway, more to that probably later; one particular thing that I’d like to avoid in this job is the XMLHTTP-request stuff.
Why ? Because I’m too lazy :) too lazy to implement it myself from scratch, and I don’t have the time to use the available implementations (and deal with their quirks/bugs).

I like things as simple and as fast as possible. I think I’m kinda a control freak, yes that explains it.

Anyway, here’s the requirement:

1. Once the staff entered an order into the system, he’ll clink into a link on the form.
This link will fill the textbox next to it with the right price for that order

That’s it. What’s going on behind the curtain is of course much more than that. Here you go :

1. The link actually invokes a JavaScript function called do_ajax()
2. The function will then append a JS element - which actually a PHP script. Thus executing the “AJAX” call
3. The JavaScript function can communicate with the server-side PHP script by way of GET method.
4. The PHP script produced its output as JavaScript code.

As simple as that.

Here are the details:

The HTML form

cn-ajax.js

cn-ajax.php

It may look complicated at first, but if you think of the cn-ajax.js as a blackbox,
then it became very simple.

NOTE: Another plus is that this form become usable for mobile warriors as well. Sure today’s PDA can do JavaScript - but speedily? Thought so.
This trick moves most of the processing to the server, with as little JavaScript code as possible. Therefore giving the best performance for these audience.

Other advantages are : clean, cross browsers, adherence to standards.
(thanks rendy ak)

Credit goes to PHPit.com for figuring these out.

TIP: Use Firefox while debugging this stuff. Its JavaScript console was a massive help to me.

OK, back to work.

phpMailman

Last year I spent about 2 weeks working on [ phpMailman ].
Unfortunately, I had to abandon it because I was assigned to other projects.

It was the most interesting projects, and potentially quite useful, that I’ve been working on. And it seems that quite a lot of others agree - I still got emails asking about it.

In short - phpMailman is a milis (mailing list) software, composed of php scripts and uses MySQL database to store its data.
It require very little to run (most webhosting package will suffice) and easy to set up. These two are things that I found lacking in other milis software.

I apologize that I’m still not able to continue my work on it. Meanwhile, I’ve updated the page with more useful information, and a link to the latest version. Hope someone will find it useful.

[ homepage of phpMailman ]

suPHP

suPHP is an Apache module which will force PHP scripts to be executed with the permission of its owner.

What does that mean ?

It means that if a script contains a vulnerability, and got exploited, then only that particular user will be affected.

This module is not supposed to be used together with mod_php, and anyway, if you’re using mod_php, any exploited PHP script will give the intruder access to everything accessible by Apache (since mod_php execute scripts as Apache’s user)

Needless to say, suPHP would be of high interest to webhosters, along with mod_security.

Useful PHP libraries

Very interesting - [ in this post ], Harry Fuecks discusses various useful PHP libraries. And there are still more suggestions in the comments. Check it out.

Cara mudah belajar Regex (regular expression)

Andrei Zmievski, developer PHP & fasilitas regex di PHP & software engineer Yahoo, baru-baru ini melakukan presentasi mengenai Regex di seminar php-works. Presentasi ini sangat bagus bagi para pemula yang ingin belajar mengenai Regex.

Syukurlah kini presentasi tersebut sudah ditaruh di website Andrei, sehingga bisa kita download secara cuma-cuma.

Download dari sini : [ Regex Clinic ].
Atau, [ download via email ] (14 MB)

Setelah menonton presentasi tersebut, jangan lupa untuk berlatih regex dengan bantuan dari Regex Coach.

Selamat belajar Regex.

Belajar PHP - cara mudah & cepat

Update: versi terbaru dari artikel ini bisa dibaca disini.

Sudah beberapa kali saya mendapat pertanyaan tentang bagaimana cara yang mudah dan cepat untuk belajar PHP. Kali ini akan saya posting disini, mudah-mudahan jadi bisa bermanfaat untuk lebih banyak orang.

  1. Install PHP & MySQL.
    Jika Anda menggunakan Windows, Anda bisa download FoxServ. Jika Anda menggunakan Linux, silahkan install Apache, PHP, MySQL; misalnya dengan merujuk kesini.
  2. Pelajari tutorial-tutorial berikut ini (sesuai urutan):
    1. Memulai belajar PHP
    2. Membuat form sederhana
    3. Membuat form yang terdiri dari beberapa halaman
  3. Agar bisa mengakses MySQL dari PHP, silahkan membaca tutorial yang bagus ini: Webmonkey.com: cara memanfaatkan MySQL dari PHP
  4. Kalau sudah memahami semuanya, bisa dilanjutkan ke 2 topik berikut ini - tidak wajib, tapi berguna/menarik untuk diketahui :
  5. Selamat ! Anda kini sudah cukup menguasai PHP - ini saat yang tepat untuk mulai mengakrabkan diri dengan cara-cara untuk mengamankan PHP

Beberapa informasi tambahan:

Semoga bermanfaat.