about 5 months ago - No comments
In a previous article I covered an example of how to log a user in using an HTML form and PHP. In another article I talked some about the global SESSION variable. Now I will show you an example of how to validate the login against a MySQL database.
In the following code it More >
about 5 months ago - No comments
// Create an array
$a = new array("apple", "orange");
// Prepend an element to the array
array_unshift($a, "raspberry");
// Prepend a couple more elements to the array
array_unshift($a, "pineapple", "watermelon");
about 5 months ago - No comments
There are two ways to add an element to the end of an array.
// Create an array
$a = new array("apple", "orange");
// Add an element to the end of the array using the array_push() function
array_push($a, "banana")
// Alternative way of adding an element to the end of an array
$a[] = "pineapple";
// Adding an element with a key
$a[’fruit’] More >
about 5 months ago - 1 comment
// Create an array
$a = new array("orange", "apple", "pineapple");
// Remove the apple from the middle of the array
unset($a[1]);
// Create an associative array
$a = new array("dogs" => 4, "cats" => 9, "birds" =>2);
// Remove the birds from the array
unset($a[’birds’]);
about 5 months ago - No comments
In a previous article we demonstrated a simple method for discovering whether or not a URL exists. The following code accomplishes the same thing, but offers a little more control.
/* Brendan Warkentin */
/* urlexists($url, $port = 80, $codes = array(200), $ssl = false)
*
* @Description:
* Determine whether a url really exists.
More >
about 5 months ago - 2 comments
A form is an area of a web page where your website’s visitors can enter information and submit it. They might fill out a contact form, or use a small form to login to your system. They come in handy and in many cases are a necessity. In this tutorial we will More >
about 5 months ago - No comments
Sending an email is easy using PHP. Create a new file, copy and paste this code, and give it a spin!
<?php
// Prepare the data
$to = ‘nobody@example.com’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers =
‘From: webmaster@example.com’."\r\n".
‘Reply-To: webmaster@example.com’."\r\n".
‘X-Mailer: PHP/’.phpversion();
// Send the email
mail($to, $subject, $message, $headers);
?>
about 5 months ago - 2 comments
Let’s say you are creating a website where users need to login. How do you track a user’s id from page to page, or even verify that a user is logged in when they should be? You can use the global $_SESSION variable!
The $_SESSION is an array where you can store your variable More >
about 5 months ago - No comments
AJAX in a word… SWEET! I love it. AJAX stands for Asynchronous JavaScript and XML. Basically it allows your web page to load content AFTER the web page has already loaded. This comes in handy when you want to perform actions on a web page or change content but don’t want More >
about 5 months ago - 1 comment
I’ve tinkered with Facebook apps enough to find out what works and what doesn’t. The most frustrating things I’ve had to deal with is when I’ve developed a Facebook app in an iframe. Using the canvas page rather than an iframe is great. You’ll encounter little to no weirdness. But if More >