CrankBerry Blog Title

PHP Postings

2010


(1) Comment

Random row from your MySQL table with PHP, alternative to ORDER BY rand()

Categories :: MySQL, PHP

Working with MySQL and PHP is awesome. Its one of the best way to manage your data, but once in a while you may want to do some randomizing. One problem I came across recently was how to select a random row from your MySQL table with PHP. Using the ORDER BY rand() method in your query maybe a bit slow so here's what we've got.

2010


No Comments

Automated MySQL database backup with PHP and cronjob

Categories :: PHP, Tools, Web Owners

At some point of working on your website you'll want to back up you MySQL database. This is they key for all of you building dynamic sites. If one day your server goes down or something you may have the files backed up but without the database you'll have to start from scratch again. If you operate a very slow-paced site then manual back up is fine but if you want to backup your database daily then it becomes tedious. I, myself is lazy so I came up with a PHP and Cronjob solution to automatically backup MySQL database.

2010


No Comments

Awesome image cropper/thumbnail maker script – Modified Marquee Tool

Categories :: Javascript, PHP

As I'm recoding my portfolio right now, I thought to myself – how great would it be to have a thumbnail maker tool. Some PHP or Javascript solution to crop images dynamically without the use of Photoshop. I would hate to fire up Photoshop every time I want to upload something. I'm sure you've all been there before. Anyways I landed upon a script that suited my need exactly. The Rectangle Marquee Tool. The tool looks great but was a bit confusing for me to get working and based on the comment for a few others too. Now I've also done some slight PHP modification to get the script working to my needs and generating the correct thumbnails.

See what I'm mumbling on about right here:
Demonstration of Marquee Tool

2010


(1) Comment

PHP password strength detector script

Categories :: PHP

If you operate a user registration script on your website you may want to ensure users are protected. There are certain aspects of this you cannot control such as the user's self selected password. Here I have a script that will detect the user's password strength and base on that you could reject the password or just make notice to the user their password's strength.

PHP Password Strength Detector Script

2009


(36) Comments

Secure PHP login without database

Categories :: PHP, Web Security

Although not recommended but maybe for some reason you need to create a PHP login without the use of any database (SQL). For some reason you maybe scared to approach, but here I made a script that is fairly secure without utilizing any database at all. It allows users to login and stay logged in. If you are one of those people then here's the script for you.

2009


(2) Comments

In page popup with faded background – in PHP

Categories :: CSS, HTML, PHP

Sometimes you may be required to have popup windows on your website. They're obtrusive and hard to style with your site, in summary – nasty. What I've seen is other websites fade out their background and have an in page popup. I came up with a script that does the same thing in PHP and it looks exactly like the image below. Jump to the next page for the script.

2009


No Comments

PHP Simple Email Validation

Categories :: PHP, Scripts and Programming

When having having forms on your website one of the most common form fields is usually the user's email. To ensure you're receiving quality information and not receiving bogus spams you should validate the email to be of a real one or close enough to. Here's a quick free email validation script for those PHP lovers.

2009


(1) Comment

PHP Image Verification aka Captcha (Basic)

Categories :: PHP, Scripts and Programming

You're making your website and you have forms. Here you are thinking, what if spam bots found my form? What if somebody submitted to my form from their own script? What should I do? Well, there's many things you can do to mitigate your worries but one of the simpler things you could do is having an image verification field in your form. Here's a basic script to generate a random code in image that bots can't read.

image verification

2009


(2) Comments

Setting PHP cron job with crontab

Categories :: PHP, Web Hosting

So you've created a PHP script that does something like clean your tables or compiles a report on some data. You want it to run it every 2 hours but you don't want to go to your computer every 2 hours. What should you do? Cron job using crontab is what you should do. Cron job is basically setting a timer on your server to run the script at a certain time that you please. Sounds easy enough, but how do you do it? Lets find out!

2009


(1) Comment

Random code and password generator in PHP

Categories :: PHP

Sometimes when you're interacting with users you need to generate a random string of code or password. For example, a user is signing up for a service and you decided to give them some random password to start with, that's what I'm talking about. Here I have a quick script which allows you to generate random code with a defined length.