Archive for November, 2005
At the heart of every dynamic website is a way for the user to interact with the data it provides, and one very common way of interacting with with such data is by the use of HTML Forms. Generally (and hopefully obviously), a form is "submitted" when the user activates an HTML input element with the type attribute set to submit. However, most user agents will also submit a form when you give focus to an input element with attribute set to text and hit return. With PHP, the most common way to test if a form has been submitted is to simply test if the $_POST/$_GET array is empty or not, however when using the aforementioned multiple submit button techniques, a problem arises:
- sensible user agents (Gecko based browser, for example) will simply act as though the first submit button had been pressed, and proceed normally.
- MSIE (Internet Exploder?) will submit the form without passing any submit elements in the resulting array, which can cause all kinds of problems if you want to test their validity
The Solution? It is perfectly valid to have multiple input elements with the same name attribute, so simply place a hidden field with the same name/value as your preferred default action. For example:
November 28th, 2005
Here's a handy little PHP function I threw together to retrieve valid entries for a MySQL ENUM/SET column, handy for generating dynamic radio group/checkbox/multiple select HTML elements:
PHP:
-
// grab possible SET/ENUM values and return an array
-
function getPossibleValues($table,$field){
-
-
$query = "SHOW COLUMNS FROM `$table` LIKE '$field'";
-
-
-
-
-
-
return $options;
-
} else {
-
-
return false;
-
}
-
-
}
November 23rd, 2005
The ubiquitous bloke in the pub is the bloke who can get you anything. He's also a web designer. Or he knows a web designer. Rather, he knows someone whose brother is a web designer and can 'knock you up a website, no problems'.
Its always amazed me that no one would trust someone to 'knock you up a car' or 'get you a cracking deal on a new tv'. No, you'd tend to go to the experts to get a car or a new tv - especially as they know what they are talking about.
November 21st, 2005
Every site on the interweb needs a domain name to be functional. The question is, what constitutes a good domain name? Anyone looking to register a new domain name these days will be hard pressed to find one that satisfies the following:
- Available for registration
- Actually relates to the site content
- Has a decent domain extension
- Optional: contains company name
We've all tried to register a domain to be told its not free. Maybe my word power is low, but I can never locate the *perfect* domain name - of course, JellyandCustard.com is that exception to the rule!
Continue Reading November 18th, 2005
Following on from Khalid's previous post on multiple submit buttons, its also worth nothing that you can have multiple submit buttons with the same name attribute, e.g:
<input type="submit" name="action" value="Edit" id="actionEdit" />
<input type="submit" name="action" value="Delete" id="actionDelete" />
So, once the form's been submitted, in PHP the $_POST['action'] var will be set to either Edit or Delete.
November 17th, 2005
There's been quite an increase recently in online income stream sites. These are basically sites that are tailored to a certain subject, and alongside the content, a few targetted adverts are placed in the hope that you, the visitor, will click on them. A good site will get a good google ranking, and a fairly decent stream of visitors. Some of these visitors will inevitable click on your adverts, and you make the money for the clickthrough. That's money that you make for doing nothing apart from setup a site, and then some search engine optimisation/listings.
November 16th, 2005
Not everyone is aware of this fact, so I thought I'd share it. You can have a single form, with multiple submit buttons, and then determine which button was clicked as to what action to take. Take the following code:
<form action="test.php" method="post"> <input type="submit" name="edit" value="edit" /><br />
<input type="submit" name="delete" value="delete" /><br />
</form>
November 16th, 2005
As an avid Apple user, I'm always on the lookout for interesting and useful apps.
I stumbled across Shiira the other day and was pleasantly suprised. Yes, it is *another* browser, but its exceptionally fast. Its based upon Web-Kit (the same foundations as Safari) and so has great compatibility, yet it appears to render pages a lot faster than Safari does...
Give it a shot.
November 15th, 2005
When I reformatted my server and put Fedora Core 4 on, I had a marked decrease in transfer speeds. Before the format, i was getting about 3mb/sec, which although is slow over a 100mbit network, it was bearable. However, after the format, I had speeds on scp throttling at about 60Kb/sec!
The confusing thing was that transfers over http and ftp were going at about 9mb/sec, ruling out any hardware problems. After quite a bit of hunting around the internet, I stumbled upon an article that I've now misplaced the link for
.
Anyhow, the fix is below.
November 15th, 2005
I decided to reformat my local webserver the other day. This server generally runs all my code on it before its published onto the web. I was using Fedora Core 4 Test 3, but decided to lose some stuff I've installed on there, and put a full release of FC4 on.
I settled on the following LAMP options:
I decided that I'd stick Oracle XE on as well, and have a play with that. Surely if MySQL is that simple to install then Oracle can't be that much harder! Or so I thought...
Read the full article (735 words & 1 image)
Continue Reading November 15th, 2005
Previous Posts