How to make an online PHP contact / phone book with simple PHP (no database)?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to make an online PHP contact / phone book with simple PHP (no database)?
Hello,
I would like to unzip a simple PHP code files, to have a online PHP contact / phone book. Simply, slow, and not database oriented over complicated setups into settings.
DokuWiki doesn't use SQL. It can also (obviously) be used as a contact manager.
thank you. sounds good wihout SQL. As a contact manager ? http://systemsboy.com/wp-content/upl...6/dokuwiki.png
I am wondering bit how , ... and it is bit heavy stuff. a contact manager would be easy to find for php, but in practice I havent found ... thanks
You will need a webserver which has installed PHP 4/5, and mySQL version 3.2 upwards.
Installation:
I went through the URL, logged in and got the sample. On the LHS, the second URL is a link to the notes. ( http://php-addressbook.sourceforge.net/demo/notes.htm ). I draw your attention to the fact that it uses mySQL (a database).
My suggestion is that if you really want to do it without a database, then use cookies - which are also another form of persistent storage. Of course, it would now be non-portable and non-scalable.
I went through the URL, logged in and got the sample. On the LHS, the second URL is a link to the notes. ( http://php-addressbook.sourceforge.net/demo/notes.htm ). I draw your attention to the fact that it uses mySQL (a database).
My suggestion is that if you really want to do it without a database, then use cookies - which are also another form of persistent storage. Of course, it would now be non-portable and non-scalable.
OK
what about the idea of dbf or dbase? Some years ago (many) that was explained and leading for databases...
[..] online PHP contact / phone book [..] WITHOUT SQL
I actually did some research a while ago in PHP, and it turns out smallish flat files (up to a few kilobytes at least) are much faster than any SQL queries, on an x86_64 Linux server. This is because of the SQL connection overhead and query construction in PHP takes longer than reading and processing a smallish flat file. For a contact or phone book, this means a flat file will be faster than any SQL solution for up to a couple of hundred contacts (assuming only names and contact information is stored).
The tricky bit is the file locking. In fact, it is so tricky most won't even try. Many hosting providers use NFS with broken file locking. PHP uses a braindead implementation of flock() which silently fails with NFS on *BSDs, and on Linux prior to 2.6.12 -- i.e. RHEL 4, CentOS 4, and that era; it will silently fail on any server using NFS with incomplete file locking support. For example, the ezPublish developers gave up on trying to get the file locking issues solved, and use an SQL database instead for the file metadata, basically just for file locking.
If your server does NOT use Windows, there is a locking procedure which is known to work (as a serialising exclusive lock). In this case, a variant where readers do not need to do any locking but modifications do and are relatively slower, should work well.
All this means that although a PHP contact list or phone book with flat file data storage is quite feasible for up to a few tens of thousand entries, it would not be portable between Windows and non-Windows servers. Most view using an SQL server as a better alternative.
Thus, you are unlikely to find such a thing, unless you write it yourself, or commission someone to do it for you.
I actually did some research a while ago in PHP, and it turns out smallish flat files (up to a few kilobytes at least) are much faster than any SQL queries, on an x86_64 Linux server. This is because of the SQL connection overhead and query construction in PHP takes longer than reading and processing a smallish flat file. For a contact or phone book, this means a flat file will be faster than any SQL solution for up to a couple of hundred contacts (assuming only names and contact information is stored).
The tricky bit is the file locking. In fact, it is so tricky most won't even try. Many hosting providers use NFS with broken file locking. PHP uses a braindead implementation of flock() which silently fails with NFS on *BSDs, and on Linux prior to 2.6.12 -- i.e. RHEL 4, CentOS 4, and that era; it will silently fail on any server using NFS with incomplete file locking support. For example, the ezPublish developers gave up on trying to get the file locking issues solved, and use an SQL database instead for the file metadata, basically just for file locking.
If your server does NOT use Windows, there is a locking procedure which is known to work (as a serialising exclusive lock). In this case, a variant where readers do not need to do any locking but modifications do and are relatively slower, should work well.
All this means that although a PHP contact list or phone book with flat file data storage is quite feasible for up to a few tens of thousand entries, it would not be portable between Windows and non-Windows servers. Most view using an SQL server as a better alternative.
Thus, you are unlikely to find such a thing, unless you write it yourself, or commission someone to do it for you.
It is too bad that there are not solution. Would someone join the efforts with me to code something?
- I really need it. I am bright in coding if I know the commands. You give me few commands and I make it for you guys. However I have no time to really learn well PHP. I have at least 30min a day for coding max + reading all included.
if you are not going to use a db
use perl to write text files you can access
Why not in PHP actually? I am not sure that the host web provider allows perl. It is not apache or I do not know what.
In PHP, as nothign exists, so I make it and would be glad of your inputs...
OK. So the first Draft of code looks like this. I created this file: "phpaddressbooktodbf.php". I need to have more fields and do not know how to link the field to a dbf field.
Do you want to maintain locally and read from the web? My first thought would be csv. Might do the trick if you don't have 'one-to-many' relationships. You probably can export your contacts to csv and ftp them to the web. php has support for csv (fgetcsv (read) from version 4, fputcsv (write) from version 5.1.0).
Just be cautious: make sure that the whole world isn't able to access your address book. I for one will not be very amused if 'my' phone number or email address can be pulled from your addressbook and is going to be used for spam. '.htaccess' can help to limit access and I strongly suggest https so info can't be sniffed (but OK, I'm paranoid).
Do you want to maintain locally and read from the web? My first thought would be csv. Might do the trick if you don't have 'one-to-many' relationships. You probably can export your contacts to csv and ftp them to the web. php has support for csv (fgetcsv (read) from version 4, fputcsv (write) from version 5.1.0).
Just be cautious: make sure that the whole world isn't able to access your address book. I for one will not be very amused if 'my' phone number or email address can be pulled from your addressbook and is going to be used for spam. '.htaccess' can help to limit access and I strongly suggest https so info can't be sniffed (but OK, I'm paranoid).
CVS is indeed a really cool idea ! indeed... I gonna check if maybe there are already some programs made for such a web contact book google my friend
You might also work with a directory of vCard files and index them by label in a CSV. From a text-processing perspective, that would take very little work in PHP.
Kevin Barry
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.