PHP is probably the best tool for the job. Java is overkill for anything except the most complex of web sites. PHP is installed on almost every web server, is relatively easy to get started with, has excellent integration with most database systems, and there are tons of features that are useful for web design.
That said, the PHP language sucks. Seriously, who decided to only use associative arrays instead of true lists? Maybe when I deleted that item I wanted to get the array indices shifted down! And what genius used completely inconsistent naming conventions for functions that act on the same data type? count, asort, array_walk, and key all act only on arrays. How about array_length, array_sort, array_walk, and array_key. Why not find the size of a variable using a function like size(value) that works on all data types? But no, each data type has to have its own set of functions that don't even have internal consistency, let alone consistency with the rest of the language.
Anyway...
Go for PHP, but be aware that it rots your brain unless you're using a decent language at the same time. To avoid brain rot and help anyone who must read your code in the future (including you) follow these pointers.
- Make things modular. That means writing functions for commonly used code, then putting them in a separate file and including that file. Use require_once to make sure you're not including files twice (hard to track down errors) and that your script will 100% die if it can't find the required file.
- Within the last few years PHP had decent object oriented programming support added on. Use where appropriate, but overkill isn't necessary (this isn't Java, after all).
- If your web host has PDO available then use it. If not, request it. PDO makes database queries easier, has an excellent interface, and is just generally easier to use. Plus if you need to change your database backend then you don't have to change around a bunch of function names.
- If there are any settings (database user names, passwords, etc.) then use a config file. I wrote a web app a few years ago for an annual competition. Out of habit I used a file named config.php. To this day the person I wrote it for just copies over the files, changes some things in config.php, creates a new database, and then he's ready to go!
- Often when you're writing a function/class in a separate file you will include the file, then want to redirect the user to another page. Make very sure that included library files don't have any whitespace before or after the PHP tags ( and ?>). You will get strange errors if there is so much as a single space.
- Sanitize your database inputs! Many exploits use unsanitized database inputs.
Happy coding!