Archive for the 'php' Category

Duplicate entries

Friday, February 3rd, 2006

Fixed a problem that caused duplicate data entries being added if you used browser’s back and forward buttons after adding a new book/movie/program to your list.
It was easy, actually :)
Fix: don’t send all those ‘page expired’ headers on the page after POSTDATA has been submitted.

Code

Sunday, July 17th, 2005

Now when database is ready, it’s time for coding.
I will describe it basically, if you want any particular details - you can always ask me.
Site is written in PHP + MySQL, there are several PHP files: main file (index.php), configuration file, some helper classes and one file per module - I made it ‘think’ about each subdomain as module, e.g. for tag.myprogs.net it loads tag.php and so on. Kinda OOP :)
All regular files (images, scripts, stylesheets) are loaded thru files.myprogs.net (configured in mod_rewrite).
Here is my .htaccess mod_rewrite configuration:

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^files.myprogs.net$ [NC]
RewriteRule ^[^.]+$ /index.php

Javascript is placed in both .js and .php files, all general scripts are in .js, and localization variables in .php
e.g. PHP code:

echo "var bad_program =\"{$Lang['program_bad']};\"";

And Javascript code in .js file:

if(bad) alert(bad_program);

Actually, you can check by yourself looking at files.myprogs.net/javascript/locale.php
I’m also using famous prototype library for easy scripting, for example I implemented suggest-like feature with it. When you add new program, it will suggest you already existed programs with similar name (LIKE query in MySQL is used here).