Programming

How to Finding Out Your Server Specs Through A PHP Script

How to Finding Out Your Server Specs Through A PHP Script

Fadıl

Have you ever need to know what your server is running?  Need to see if it runs MySQL?  Well here is a way of knowing what options are available in PHP and what’s going on in your server is to use the phpinfo() function. Create a script with the following.

<html> 
<body> 
<?php 
phpinfo(); 
?> 
</body> 
</html>

Save and view this script through your Web server. You’ll see a page filled with useful and interesting information.  This info tells all about your server, internal Web server environment variables, the options that are compiled, and on and on.
I hope it has been a useful article.

How to Creating A Page Counter In PHP

Fadıl

OK,  everybody has a hit counter on their page.  But how many people actually make their own?  Ya well, I am going to show you how to create a simple page counter in PHP.

This page counter writes to a file that you have created, storing how many hits you have received.  The script then reads the text file (counter.txt) and displays it on the page.  Let’s take a look at this code in action.

Writing To A File Using Fopen

Fadıl

Their will be many different instances when you might need to write to a file.  What we are going to do now is create an HTML form, and a PHP code so when you click submit on the HTML form it writes the users input to a file.

In this PHP script, we are going to be using the /n function, fopen, fput, and fclose commands.

First, we are going create an HTML page that has the following code.

How to Sending E-mail With PHP?

Fadıl

Every web site has email.  Rather it being a feedback form of some sort or a mailto: tag, why make it hard for the visitor to contact you?  When you can take 3 lines of code and create a feedback form the directly sends it to your email from the web browser with the visitor’s input.

Creating a PHP Email form could be the best thing that has ever happened to your site.  So how do you do it? Easy.
You can have any one of your pages send an email when the visitor either visits the page or if the visitor has submitted some sort of input.  When you add the code it needs to be at the top of the page you would like to send from.

Ip Check Using PHP

Fadıl

If you have ever had the need to validate an IP address then this small script is for you.

function validate_ip($ip) {
if (is_string($ip) && ereg('^([0-9]{1,3}).([0-9]{1,3}).' .
'([0-9]{1,3}).([0-9]{1,3})$',
$ip, $part)) {
if ($part[1] <= 255 && $part[2] <= 225 && $parg[3] <= 255 && $part[4] <= 255)
return TRUE; # Valid IP
}
return FALSE; # Invalid IP
}

Ok, that’s all fine and dandy but what does it mean?

The fist if the statement is breaking the IP up into 3 sections and removing the ‘.’ from the user input. It then stores the results in the $part var then the second If statement checks to see if all of the parts are valid. If everything is fine and dandy it will return TRUE and if something has gone wrong it will return FALSE.
Hope this helps anyone.