It is very simple code that displays the HTTP_USER_AGENT of the client and shows what version and the name of the browser that the user is working on.
This small sample script gives some examples of how the browser detector can be used, in the first case it will print out the browser with version number, and the operating system with version number.


My Coding Part
<?php
$yourbrowser= $_SERVER ['HTTP_USER_AGENT'];
echo “<b>Your Browser User Agent is</b>: “ . $yourbrowser;
?>
(more…)
|
No Comments »
Create an Upload File Form
This is a tutorial regarding uploading file using PHP. You need to build a HTML form that lets users to select a file to upload. See my sample code for a more details at forms.

There are a couple of important things to note:
- An upload form is another type of input form, simply set the input type attribute to file.
- Set the attribute of form called enctype to “multipart/form-data”. This means that the form require the contents of a file, to be uploaded.
(more…)
|
No Comments »
This is a continued lesson of last week tutorial Simple PHP & MySQL User Login System(Part 1).
Step 5: Create the User Login Form (login-form.php)

I have created the login form for user to enter their login and password. It includes 2 fields “login” and “password” and submit button “Login”.
<
html>
<
head>
<
title>Login Form<
/title>
<
/head>
<
body>
<
form id=”loginForm”
name=”loginForm”
method=”post”
action=”login-exec.php”>
<table width=”300″ border=”0″ align=”center” cellpadding=”2″ cellspacing=”0″ style=”font-family:Arial;font-size:11px”>
<tr>
<th>Login</th>
<td><input name=”login” type=”text” id=”login” /></td>
</tr>
<tr>
<th>Password</th>
<td><input name=”password” type=”password” id=”password” /></td>
</tr>
<tr>
<td></td>
<td><input type=”submit” name=”Submit” value=”Login” /></td>
</tr>
</table>
</form>
</body>
</html>
(more…)
|
2 Comments »
Today I’m going to teach you how to create a simple user login script with user levels by using PHP and MySQL. To start with this we will need a table in our database, which will hold the user records.
Features included:
- User Registration Form
- User Login Form
- User Logout Form
Step 1: Create the Database Configuration File (config.php)
You need to create a configuration file that stores the MySQL database connection settings. Creating a separate file for MySQL database connection settings is better since you may have to change your MySQL server, username, password or database in future.

<?php
define(‘DB_HOST‘,’localhost‘); //hostname
define(’DB_USER‘, ‘codebasic‘); //username
define(‘DB_PASSWORD‘, ‘123456‘); //password
define(’DB_DATABASE‘, ‘mydatabase‘); //database name
?>
Note: No need follow exactly. You can replace the settings above with your MySQL database settings.


(more…)
|
2 Comments »
This week, I will provide this tutorial that will guide you on how to make a simple PHP hit counter. This is great as you will be able to show your visitors how many times your web page has been loaded.
Tutorial On Creating PHP Visitor Hit Counter
Step 1: Create a script called ‘visitorhit.php‘ and a text file called ‘counter.text‘ with a value of 0 and save it to the same directory as your php file.


Note: Make sure that your text file has enough permissions, so set the permission CHMOD to 777.
Step 2: Start your PHP coding now, open your ‘visitorhit.php’ and set the variable for the file named ‘counter.text’ and place this between your PHP tags.
Note: Remember to place the filename in quotes and make sure that the semicolon is placed on the end of the line.
<?php
$number_of_visit = (”counter.text”);
?>
Step 3: Then you need to have the file to open it and tell PHP to read the number inside. Set the number of visits ($hits) to the current value of the counter.text file.
<?php
$number_of_visit = (”counter.text”);
$hits = file($number_of_visit);
?>
Step 4: Then, it must increase the value by 1 for the current hit when the page is loaded or refreshed. Thus, add 1 to your current value of $hits. $hits should now be whatever’s inside the file “counter.text” plus one. It means that if inside your text file is 0, then $hits should equal 0 + 1 = 1.
<?php
$number_of_visit = (”counter.text”);
$hits = file($number_of_visit);
$hits[0] ++; // $hits = $hits + 1;
?>
(more…)
|
1 Comment »