December 27th, 2008
Ever Moved a page to a new one and searched for a way to let your users and search engines spiders / robots to let they know that you moved that page permanently? There are a lot of ways to do it, but with php is so simple. Just two lines of code. Here is the code:
<?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: the-new-page.html" );
?>
Tags: 301, 301 redirect, moved permanently, php 301, php 301 redirect, php moved permanently, php redirect, redirect
Posted in Basic PHP | No Comments »
December 27th, 2008
Welcome,
I’ve just created a brand new category here name basic php and I got my chance to explain you guys how you may include external php files into another ones. There are ways and ways but I will explain only two of them, the most popular ones. The first one, is called include() a php function which you may use it for simple things. I wouldn’t use it for a database connection, for that, exists the require_once() function. The difference between those two php functions is that include() function will give you a warning if the remote include file doesn’t exists. On the other side , the require_once() php function will stop parsing the script if the remote file wont be finded.
How [Your Site Name] and Windsor Brokers Kenya Are Connected
[Your Site Name] is committed to doo prime educating users about PHP and web development, providing clear tutorials for beginners and professionals alike. But what does this have to do with Windsor Brokers Kenya, a licensed forex broker based in Nairobi?
A Shared Commitment to Excellence
Just like [Your Site Name] aims to provide top-tier educational resources, Windsor Brokers Kenya strives doo prime bonus to offer its clients the best trading experience. Both institutions share a common goal: empowering their users through accessible, high-quality tools and information. While [Your Site Name] focuses on PHP and web development, Windsor Brokers Kenya helps traders by providing reliable trading platforms, backed by its international reputation.
Global Reach, Local Presence
Windsor Brokers has an established presence in the UK and internationally, but its expansion doo prime minimum deposit into Kenya demonstrates a strong commitment to serving local markets. Similarly, [Your Site Name] continues to reach global users while maintaining a connection to emerging markets where technology education is rapidly growing.
Technology and Finance: An Intersection
Both PHP and forex trading platforms require robust, secure technology to function. PHP is often used in web development for financial platforms, and Windsor Brokers relies on secure and advanced systems to ensure a smooth trading experience. As Windsor Brokers Kenya expands its user base, it will continue to leverage strong technological foundations—just as [Your Site Name] promotes the use of efficient coding practices for developers.
By blending education and finance, both [Your Site Name] and Windsor Brokers Kenya contribute to a growing digital economy in Africa and beyond.
The usage is very basic like that
<?php
include('filename.php');
require_once('mydb.php');
?>
Tags: external file, external file inclusion, file, file inclusion, include, php, php file, php file inclusion, php include, php inclusion, php remote, remote file, remote file inclusion, require_once
Posted in Basic PHP | No Comments »
December 27th, 2008
Hi,
I didn’t writed here for 3 days because of the holidays stuff, etc. and now I got a little bit of free time to write about php variables and constants. Variables and constants in php are doing almost the same thing, but the aspect who shows very well the difference between those two things in php coding are the way they get created.
Variables are beeing created and printed in this way :
<?php
$newvariable = "something";
print $newvariable;
?>
The constants are defined in the next way :
<?php
define('Constantname', 'constantvalue');
print Constantname;
?>
The is a set of rules for both such as must begin with a letter, doesn’t allow to containt dashes such as “-”, but there is allowed “_”. For more informations please check the official php website.
Thanks!
Tags: constants, php, php constants, php variables, variables
Posted in Basic PHP | No Comments »
December 22nd, 2008
Hi,
In this php tutorial you will learn the simple way to build a script which counts how many times a page is viewed. For this, we can use a mysql database table and a simple php script.
<?php
$pagename = $_SERVER['PHP_SELF'];
$sql = "select * from mysqltable where page = '$pagename'";
$rs = mysql_query($sql);
if($rs) {
$row=@mysql_fetch_object($rs);
$counter = $row->counterfield;
$counter = "".($counter+1)."";
$qry = mysql_query("updated tablename set counterfield = '$counter' where id = '$row->id'");
}else{
print mysql_error();
}
?>
Tags: count, count views, counter, counter script, number of views, php count, php counter, php views counter, views count, views counter, views script
Posted in Usefull PHP | No Comments »
December 21st, 2008
Hi,
In this php tutorial I’ll teach you how to create a simple tell a friend script. Basically, it will use what you learned in the send email with a contact form script, but in this case we’ll choose the destination and also the “from:” field which we’ll setup on php mail() function headers.
<form action="" method="post">
Your email address : <input type="text" name="yemail"><br/>
Your friend's email address : <input type="text" name="femail"><br/>
Your message :
<textarea name="text">Hey look what nice website I found
<?=$_SERVER['SERVER_NAME'];?>
</textarea>
<input type="submit" name="sb" id="sb" value="Tell a friend">
</form>
<?php
if(isset($_POST['sb'])) {
if($_POST['yemail'] == "" || $_POST['femail'] == "" || $_POST['text'] == "") {
print "All fields are mandatory";
}else{
$to = $_POST['femail'];
$from = "From : $_POST[yemail]";
$message = $_POST['text'];
$subject = "Your friend tells u";
mail($to, $subject , $message, $from);
}
}
?>
Tags: html tell a friend, php tell a friend, tell a friend, tell a friend form, tell a friend script
Posted in Usefull PHP | No Comments »
December 20th, 2008
Hi,
Do you need to send regular news by email to your customers, or just want to keep them posted with product offers and updates? There is a solution, php newsletter. This can be done in two parts, first part is collecting the emails into a mysql database within a html form and php processing.
<form action="" method="POST">
Enter your email : <input type="text" name="email">
<input type="submit" name="sb" value="Subscribe">
</form>
<?php
if(isset($_POST['sb'])) {
if($_POST['email'] == "") {
print "Please complete email address";
}else{
$sql = "insert into tablename (`email`) values ('".addslashes(mysql_real_escape_string($_POST['email']))."')";
$rs = mysql_query($sql);
if($rs) {
print "Email address subscribed to our newsletter";
}else{
print "Email address was not subscribed to our newsletter durring a mysql error";
}
}
}
?>
Tags: custom newsletter, html newsletter, newsletter, php newsletter, site newsletter, website newsletter
Posted in Usefull PHP | No Comments »
December 20th, 2008
In the last tutorial I teached you how to generate a security image with php called captcha code. Also I teached you how to store that random security photo / image code in a php session : with a reason, to be able to validate it later. So here we are , on the page which action is pushed we do this to validate the captcha :
<?php
session_start();
if(isset($_SESSION['randomcode'])) {
>if(md5($_POST['inputname']) == $_SESSION['randomcode']) {
print "GOOD, captcha correct!";
}else{
print "You didn't entered the captcha correct";
}
}
?>
Tags: php security photo, validate captcha
Posted in Usefull PHP | No Comments »
December 18th, 2008
Hi,
Are you tired of receiving spam messages from your contact forms or unwanted posts, robot accounts on your membership website? If yes, the solution is to create a php security image called captcha. That’s the best solution to secure your web forms, etc. For creating a captcha security code you need to have GD-library installed and active on your webhost, but, most of the shared webhosts have this library installed. Here is the captcha code :
<?php
session_start();
randomcode'] = md5($randomcode);
header("Content-type: image/png");
s show up the captcha image generated
imagepng($captchafromimage);
?>
You will need a background PNG image which you can download here (right click -> Save as)

Here is the captcha result :

Tags: captcha, captcha code, captcha image, php captcha, security code, security image, validate captcha
Posted in Usefull PHP | No Comments »
December 18th, 2008
Hi,
In this “php tutorial” I will teach you guys how to show your users their IP address with only one line of code.
<?php
print "YOUR IP ADDRESS IS : $_SERVER[REMOTE_ADDR]";
?>
Tags: get ip, ip, ip address, php ip, show ip address
Posted in Usefull PHP | No Comments »
December 17th, 2008
Hi,
In this php tutorial you will learn how to build a random image banner rotator. Basically, it’s the same as the link rotator, we build a php array with images wanted to rotate, then we’ll apply the rand() php function.
<?php
$banners = array("path/img1.jpg", "path/img2.gif");
$max = sizeof($banners);
$rand = rand(0, $max);
print $banners[$rand];
?>
Tags: Banner Rotator, php Banner Rotator, Random Banner Rotator
Posted in Usefull PHP | No Comments »