Archive for May, 2007


Sunday, May 27th, 2007

Over the following weeks I will be covering PHP code which stands out to myself and some code which I use regularly. These PHP codes will be mentioned every week with an explanation on their uses. The section is called “PHP code of the week“.

We begin with our first PHP code of the week: HTTP_POST_VARS and HTTP_GET_VARS. Without these two functions we wouldn’t be able to get data from forms or simplify the way we specify user input in our code.

HTTP_POST_VARS is the function we call when we want to retrieve variable input from a form that the user has submitted. Say we have a field in the form called username. To retrieve the value of username we would write it as:

[php]$username = $HTTP_POST_VARS[‘username’];[/php]

So we have the username fields value being assigned to a local variable $username.

is commonly used when searching forums, looking up user names, etc so you have most likely seen it been used. It is a simple way to input values into your code and is done by placing a question mark (?) and variable name and the value after the file we are requesting.


In the above case, we can see that we are requesting the view_user.php file and are wanting to find more information on the userid number 5.

The inside code would look like:

[php]$user_id = $HTTP_GET_VARS[‘userid’];[/php]

That’s pretty simple, we have the userid variable being assigned to the local variable $user_id.

Using HTTP_GET_VARS you are also able to retrieve more than one variable by placing a ampersand sign after each value. Such as:


So there you go, you now know how to retrieve user data.

If you are requesting the values and say the user didn’t input anything in the POST/GET request, 0 (false) is assigned to the local variables.

Note: These examples aren’t recommended to be placed directly into code as there are security issues. You should use functions such as htmlspecialchars, intval and str_replace before touching the variables. These functions will be covered in the next PHP code of the week.

Add Text to Title When Locking Topic v0.1.0

Sunday, May 6th, 2007

I’ve made another new phpBB mod called Add Text to Title When Locking Topic which allows the administrator or moderator to input some text and select whether the text will be added before or after the topic title.

They can then click the lock icon in the viewtopic page which will lock and add the text to the title. They can also select multiple topics from the moderator control panel and perform the same action as well.

Deny Posting Text and BBcode Until x Posts v1.0.3

Sunday, May 6th, 2007

Deny Posting Text and BBcode Until x Posts has been updated to v1.0.3 as a user was using heaps more text than I though people would. So instead of storing the text list in an array in the config table it’s now got it’s own table.

You can download v1.0.3 or upgrade from v1.0.2 here.