Hier de scripts:
INDEX.PHP
<html>
<head>
<title>login page</title>
</head>
<body>
<center>
<h1></h1>
<br>
Login
<table>
<tr>
<td>
<form method="POST" action="loginproc.php">
<p>username: <input type="text" name="username" size="20"></p>
<p>password: <input type="password" name="password" size="20"></p>
<p><input type="submit" value="Inloggen" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
LOGINPROC.PHP
<?php
session_start();
$server = "localhost";
$username = "*******";
$password = "********";
$db_name = "********";
$db = mysql_connect($server,$username,$password) or DIE("Connection to database failed, perhaps the service is down !!");
mysql_select_db($db_name) or DIE("Database name not available !!");
$login = mysql_query("select * from ******* where (username = '" . $_POST['username'] . "') and (password = '" . md5($_POST['password']) . "')",$db);
$rowcount = mysql_num_rows($login);
echo "";
if ( $rowcount == 1 ) {
$_SESSION['username'] = $_POST['username'];
header("Location: securedpage.php");
}
else
{
header("Location: index.php");
}
?>
SECUREDPAGE.PHP
<?php
session_start();
if (!isset($_SESSION['username'])) {
header("Location: loginproc.php");
}
?>
<html>
<head>
<title>U bent ingelogd</title>
</head>
<body>
<center>
<table>
<tr>
<td>
<p>U bent succesvol ingelogd met gebruikersnaam <? echo $_SESSION['username']; ?></p>
<br>
<br>
<br>
<?php
/**
* Main File
*
* To show the result in your php page, you can include this file into your php page example:
* <?php
* include dirname (__FILE__) . "/whatsyourip/index.php";
* ?>
*
* Copyright (C) 2008. IPDistance.com
*/
require_once dirname (__FILE__) . "/lib/class.hostIp.php";
require_once dirname (__FILE__) . "/config.php";
$IP = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr ($IP);
//get ip informations
$hostIp = new hostIp ();
$locations1 = $hostIp->getLocations ($IP);
$cityInfo = $locations1["City"];
$countryInfo = $locations1["Country"];
if (!empty ($cityInfo))
$countryInfo = $cityInfo . ", ". $countryInfo;
$latitudeInfo = $locations1["Latitude"];
$longitudeInfo = $locations1["Longitude"];
$imgFlag = $hostIp->getImgFlag ($IP);
?>
<style>
<?php
include dirname (__FILE__) . "/style.css";
?>
</style>
<span id="title">Uw ip adres is:</span>
<br>
<span id="result"><?php echo $IP ?></span>
<br>
<?php
if (!empty ($hostname))
{
?>
<br>
<span id="title">Uw hostname is:</span>
<br>
<span id="result"><?php echo $hostname?></span>
<br>
<?php
}
?>
<?php
if (!empty ($countryInfo))
{
?>
<br>
<span id="title">Uw huidige lokatie is:</span>
<br>
<span id="result"><?php echo $countryInfo ?>
<img src='<?=$imgFlag?>' height='15'></span>
<?php
}
?>
<br>
<p><a href="logoutpage.php">uitloggen</a></p>
</td>
<td>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Kies een bestand: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</td>
</tr>
</table>
<br>
<br>
<br>
</center>
</body>
</html>