Codice:
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$db_host="localhost";
$db_name="nomedb";
$db_user="nomeuser";
$db_password="pass pannello di controllo";
$db=mysql_connect($db_host,$db_user,$db_password);
if ($db==false) die("Errore nel collegamento a MySQL!");
mysql_select_db($db_name,$db)
or die("Errore nella selezione del database!");
$query="CREATE TABLE IF NOT EXISTS info (
id int NOT NULL auto_increment,
ip int default 0,
PRIMARY KEY (id) )";
mysql_query($query,$db)
or die("Errore nell'invio della query!");
$query="INSERT INTO info (ip) VALUES ('$ip')";
mysql_query($query,$db)
or die("Errore nell'invio della selezione!");
?>
<?php
mysql_close($db);
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Sito in costruzione</title>
<meta name="description" content="">
<meta name="author" content="">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,700,400italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Nunito:700' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]>
<script src="http://im.altervista.org/site_index/html5shiv.js"></script>
<![endif]-->
<style type="text/css">
article,
aside,
details,
figcaption,
figure,
footer,
header,
nav,
section,
summary {
display: block;
}
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
margin: 0;
padding: 0;
font-family: 'Source Sans Pro', sans-serif;
font-size: 15px;
color: #333;
line-height: 1.5;
background-color: #f4f4f4;
}
a {
color: #f49600;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:focus, input {
outline: 0 none;
}
img {
border: 0;
max-width: 100%;
}
.align-left {
float: left;
margin: -10px 10px 0 0;
}
.align-right {
float: right;
margin: -10px 0 0 10px;
}
p {
margin: 20px 0;
padding: 0;
}
hr.spacer {
height: 0;
padding: 0;
margin: 0 0 20px 0;
border: none;
border-bottom: 1px solid #efefef;
clear: both;
}
/* Clearing floats */
.clearfix:after {
clear: both;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix {
*zoom: 1; /*For IE 6/7 only */
}
.clear {
clear: both;
}
/* Layout */
#site {
max-width: 1600px;
width: 100%;
margin: auto;
padding: 0;
}
.main {
max-width: 800px;
width: 100%;
margin: auto;
}
#page-header {
height: 50px;
background: #21324a;
overflow: hidden;
}
#page-welcome {
width: 100%;
background-color: #3064c6;
background: linear-gradient(to bottom, #366ed2, #264eac); /* W3C */
background: -moz-linear-gradient(top , #366ed2, #264eac);
background: -webkit-linear-gradient(top , #366ed2, #264eac);
color: #fff;
}
#page-welcome .main {
padding: 20px 0 0 0;
}
#page-wrap {
background: #fff;
}
#page-footer {
color: #777;
text-align: right;
font-size: 14px;
background: #efefef;
}
#page-footer .main {
padding: 20px;
}
/* Typography */
h1 {
font-size: 38px;
color: #21344A;
margin: 40px 0 20px;
padding: 0;
font-weight: 300;
line-height: 1.2;
}
h1.site-title {
margin: 0;
padding: 30px 0 0;
color: #fff;
text-align: center;
letter-spacing: 0.05em;
}
h3 {
font-family: 'Nunito', sans-serif;
font-size: 22px;
font-weight: 700;
margin: 20px 0 10px;
color: #21344A;
line-height: 1.2;
}
h4 {
font-family: 'Nunito', sans-serif;
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
margin: 20px 0 10px;
color: #21344A;
}
/* Main */
.texture {
background: url("http://im.altervista.org/site_index/texture.png") repeat-x center top;
width: 100%;
min-height: 300px;
}
.col2 {
width: 50%;
float: left;
}
.row .col2:first-child {
padding-right: 20px;
}
.brand {
display: inline-block;
margin: 3px 0;
height: 44px;
text-decoration: none;
}
.nav {
float: right;
text-align: right;
color: #d8dadc;
margin: 0;
padding: 16px 0 0 0;
font-family: 'Nunito', sans-serif;
font-size: 12px;
text-transform: uppercase;
font-weight: 700;
}
.nav li {
display: inline-block;
padding: 0 0 0 20px;
margin: 0;
}
.nav li:first-child {
padding-left: 0;
}
.nav a {
color: #d2d5da;
}
.article {
padding: 20px;
border-top: 1px solid #efefef;
-webkit-box-shadow: 0 3px 4px -1px #FAFAFA inset;
box-shadow: 0 3px 4px -1px #FAFAFA inset;
}
.main .article:first-child {
-webkit-box-shadow: none;
box-shadow: none;
border: none;
}
ul {
list-style-type: disc;
margin: 0 0 20px 40px;
padding: 0;
}
ul li {
padding: 5px 0;
margin: 0 0 5px 0;
}
h4.info {
background: url('http://im.altervista.org/site_index/icon-info.png') no-repeat 0 0;
height: 30px;
line-height: 30px;
padding: 0 0 0 40px;
}
h4.help {
background: url('http://im.altervista.org/site_index/icon-help.png') no-repeat 0 0;
height: 30px;
line-height: 30px;
padding: 0 0 0 40px;
}
.site-action {
text-align: center;
font-size: 18px;
margin: 10px 0 0;
}
.goodby {
margin: 0;
padding: 20px;
border-top: 1px solid #efefef;
color: #777;
-webkit-box-shadow: 0 3px 4px -1px #FAFAFA inset;
box-shadow: 0 3px 4px -1px #FAFAFA inset;
}
.button {
background-color: #6CAC0E;
border-bottom: 3px solid #568A0B;
border-radius: 3px;
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
color: #FFFFFF;
cursor: pointer;
display: inline-block;
font-family: 'Source Sans Pro', sans-serif;
font-size: 16px;
font-weight: 400;
padding: 7px 24px 6px;
text-align: center;
text-decoration: none;
text-shadow: 0 1px 1px #568A0B;
margin: 40px 0 20px;
}
.button:hover {
text-decoration: none;
background-color: #59A9F4;
border-bottom-color: #3E73F1;
}
#page-footer a {
color: #777;
}
#page-footer a:hover {
color: #21344A;
text-decoration: none;
}
/* Smartphones ----------- */
@media screen
and (max-width: 480px) {
#page-header .nav {
display: none;
}
#page-header .main {
text-align: center;
}
.align-left,
.align-right {
display: block;
float: none;
margin: 0 auto;
}
.row .col2 {
float: none;
width: 100%;
}
#page-footer {
text-align: center;
}
ul {
margin-left: 20px;
}
}
</style>
</head>
<body>
<div id="site"><!-- / #page-header -->
<div id="page-welcome">
<div class="texture">
<div class="main">
<h1 class="site-title">Benvenuto su modelleAG</h1>
<p class="site-action">Sito momentaneamente offline.<br /> Riprova più tardi.</p>
</div>
</div>
</div>
<!-- / #page-welcome --></div>
</body>
</html>
il problema e che non crea la tabella nel db. so che non ci sono controlli se l'ip è presente o cose del genere, ma è solo un'esercitazione.