Articles in the PHP Category
PHP, Tech Corner »
This tutorial shows you how to build a simple login form and to check the login credentials entered against te database using PHP and MySQL.I had introduced some PHP lessons earlier.It might be worth to take a look at them before you go through this.Anyway,this isnt any harder.I have specially included this as an article because a login form is an essential component of most dynamic websites.
Again we are using MySQL database.Create a database(here i have created one called as “test”).Now create a table ‘login’ with two fields namely ‘username’ and ‘password’.Make ‘username’ the …
PHP, Tech Corner »
PHP in little over 14 years have become one of the most popular prgramming language for web development.PHP or Hypertext Preprocessor’s have become popular on account of its ease of use,scalability and wide spread support for various databases and data formats.Another aspect of its ever growing popularity is that it is open source and hence freely available on the internet.These are the main reasons why PHP is used in over 30 million websites and more than one third of the web servers.
The earliest version of PHP,codenamed as PHP/FI was a …
PHP, Tech Corner »
Here i will show how to make an image gallery using PHP’s File Manipulation functions.The code basically generates a web page to display image by scanning a specified directory.
For this first we need to define the location of the images.This directory should be accessible by the script owner,meaning you should have read permissions on the directory.The directory can be defined as follows:
$photosDir = ‘./photos’;
If you are using Wamp server,create the folder ‘photos’ inside the ‘www’ root folder for the above code to work.Now set up an array …
PHP, Tech Corner »
As you would have noticed in the earlier posts,the $_GET and $_POST variables are used to retrieve information from a web form.All HTML form elements are automatically available to the PHP script.Lets see how the form elements are made available to the PHP script.
<html>
<body>
<form action=”welcome.php” method=”post”>
Name: <input type=”text” name=”username” />
<input type=”submit” />
</form>
</body>
</html>
Now when the submit button is clicked,the “welcome.php” script is called,which looks something like this
<html>
<body>
Welcome <?php echo $_POST["username"]; ?>!
</body>
</html>
The above form passes values using the “post” method and hence the $_POST function is used to retrieve the form data.
The …
PHP, Tech Corner »
The time() and date() functions are the most used date/time functions in PHP.The time() function returns the current time as a unix timestamp.The date function can be then used to format this value to be human friendly.This is shown in the below example.
$CurrentTime=time();
echo(date(”F d Y”,$CurrentTime));
?>
Output: January 1 2009
Another time function used is mktime().It is similar to the time() function except that it outputs a specified date and time and not the current time.In effect it artificially generates a timestamp based on inputed date and time.
The format for mktime() is
mktime ( …