PHP Script Archive
About Isset()
According to php.net PHP Isset is:
Determine if a variable is set and is not NULL.
If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. Also note that a NULL byte (“\0″) is not equivalent to the PHP NULL constant.
If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. Evaluation goes from left to right and stops as soon as an unset variable is encountered.
What does that mean? Bascially, if the users clicks a button, you want to see if they did it.
$info = ""';
if (isset($info)) {
echo " Info is blank";
}
The above script will validate if info is set or not.
Category: PHP Script | No Comments »Simple Login Script
After creating a database named users, a table named users and two fields username and password, you can begin making this login script.
The basic form
Create a page named index.php, and inside that page add the following code.
<form action="login.php" method="post"> <label for="name">Username</label> <input name="username" type="text" /> <label for="password">Passwod</label> <input name="password" type="password" /> <input type="submit" value="submit" /> </form>

photo credit: Laughing Squid
The form action tells the form where the information should be going once the submit button is clicked. Next, the method tells it how the information should be transmitted. In PHP there are two methods for tranmitting information,
- Post
- Get
Remember visiting Youtube and seeing youtube.com/watch?v=mEj-88iLjmM&feature=popular? This was submitted using a get, because you can see everything that is going on.
In cases where security is important this is not system, we do not want people to be able to hi-jack our login credentials.
We have basic input boxes. The “name” value is what is transmitted to the subsequent PHP pages.
Connecting to a database
Make a new document and name it: “connection.php”. This document will store the database connection information.
We have the variables stored with our database information, now we need to do something with them. Take the server location (most cases its localhost), database user, and database password and connecting. or die(mysql_error()) says, if connection does not complete, give us an error message.
Next, we select the database, and if something went wrong there, we display another error message.
We want to include this on every page that needs database access.
Category: PHP Script | No Comments »CakePHP- First Impression
Recently I got an introduction to frameworks. Although there a several hundred different types each offering a different set of features and abilities I focused on one the more popular PHP Frameworks.
Here is a list of PHP Frameworks. The list is astonishing. The most popular frameworks are CakePHP, Zend, and Code Igniter.
The people developing CakePHP have created a very through framework that allows easy database access. CakePHP is uses a Ruby on Rails convention, of several folders that break apart the code for pages. This can be extremely confusing for the beginner. After working with the system you quickly understand the purpose.
In future posts I will explain CakePHP development further. CakePHP has a well developed base of people to help program with the framework.
Have I missed your favorite framework?
Category: PHP Script | 2 Comments »Why use an array?
Recently, I asked myself the same question. You might be wondering, what is an array. According to Wiki:
In computer science an array [1] is a data structure consisting of a group of elements that are accessed by indexing.
What does that really mean? Well, I’ll explain by using an example I got off one of the programming forums I frequent, SamponVideos.com. I will actually quote some of Johnathan Sampson’s message because it captures the idea. In his example, if you were creating a an image uploader, and you did not want to allow executable files, you would do something like this:
$fileTypes = array("jpeg","gif","jpg","bmp");
Without the use of an array, it would turn into this:
if ($fileExtension == “jpeg”) {
# Approved
} else
if ($fileExtension == “gif”) {
# Approved
} else
if (fileExtension == “jpg”) {
# Approved
}
Or this:
if ($fileExtension == “jpeg” || $fileExtension == “gif” || $fileExtension == “jpg”) {
# Approved
}
The array makes the code, much easier to handle, and looks cleaner. Have you used arrays in your projects?
Category: PHP Script | No Comments »Easy Site-Wide Link Updating
As I have created more websites, I have come to love includes. They are useful when you need to use one file repeatadly. For instance, you may want the same navigation scheme across a site. It would be troublesome, or bothersome to insert you navigation code on each page.
What happens when you add or subtract a page? You would have to change every single page. 9 times out of 10, you always miss at least one page. There are other situations where using an include would come in handy, but those are more programming oriented.
You will need:
This code requires the use of PHP, on the main page you need to write, and so this page must end in .php, for example, index.php. The ending php tells your server it needs to do more work with that page before displaying it.
Whenever you are using a PHP tag, you must enclose it in
<?php **Place Code Here** ?>
On the every page you want this content to appear insert the code:
<?php include(“file directory here/link.html”); ?>
This tells the server to include “file.html” in that place on the page. Now, you create “link.html”.
<ul>
<li><a href=”index.php” title=”Home”>Home</a></li>
<li><a href=”contact.php” title=”Contact Us”>Contact Us</a></li>
<li><a href=”location.php” title=”Location”>Location</a></li>
</ul>
Now upload these pages to your webserver and only update “link.html” as needed.
Category: PHP Script | No Comments »Automatic Copyright Updating
Many people who design websites put copyright dates on every page of their website. By inserting this snippet of code your site will bringing in the new year with an up to date copyright date.
Today this snippet will output Copyright 2008 Resnodesigns and next year, it will greet the New Year with Copyright 2009 Resnodesigns.
Copyright <? echo date("Y"); ?> Resnodesigns
Category:
PHP Script |
No Comments »






