Archive for the ‘PHP’ Category

Buggy header in php


Today, I got a problem in a php script. I was using header() function in the if-else branching. The code is something like
if(condition1)
{
header(”Location:dummy.php?err=1″);
}
else
{
header(”Location:dummy.php?err=2″);
}
if(condition2)
{
header(”Location:dummy.php?err=3″);
}
else
{
header(”Location:dummy.php?err=4″);
}
a contition may fullfill both condition 1 and 2. But in this case I want to go through the first if clause. I run the script and saw that the final page is [...]

No Comments

Move uploaded file problem


Today I faced a new problem in php coding. I was coding a simple file uploader class. I used regular script as I do. A warning is found at move_uploaded_file() function. I passed some time googling about it. I found that the function cannot access the directory I have mentioned. I made a command on [...]

No Comments

PHP mail function


Many people practise php on a virtual server on the desktop. Since the local hsot of the desktop is not registered to any Internet Service Provider, all the php built in function will not  work in local host.
Few days ago, I was trying to send mail from my localhost. Everytime it says undefined function. I [...]

Tags:

No Comments

Tracking an user


Tracking an user is very easy in php. It requires a single line to get the client ip address.
The line is $ip=$_SERVER['REMOTE_ADDR'];
Easy. Isn’t it?
Just put the following code in a php file and upload to your domain.
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
Then open the page using your browser. It will print your ip address. Check it.
If you do this [...]

No Comments

PHP header already sent error


Few days ago I made a silly mistake in my php coding. I have echoed something on the page where I have set the cookie.  It seems that it is not faulty code. I googled the problem and found the solution from php.net. Actually cookie must be called before anything goes to browser from server.
So [...]

No Comments

PHP CAPTCHA generator


CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart. The term captcha was first coined by Luis von Ahn, Manuel Blum, Nicholas J. Hooper and John Langford. The first three are from Carnegie Mellon University and last one is from IBM. We will see how easily we can produce captcha [...]

No Comments

Pie diagram in PHP


PHP is a very powerful web scripting language. We can easily create images on web page using php.
Now the question is there are thousands of image editing software to create marvellous images, why we need php script to draw image for us.
The answer is php is dynamic. Most of the image editing software are designed [...]

No Comments