Codice PHP:
<?php
$db = "database.txt"; // in questo file verranno salvati i dati.
$_SESSION["titolo"] = $_POST["element_1"];
$fp = fopen($db, "a+");
fwrite($fp, $_POST["element_1"] . " | " . $_POST["element_8"] . " | " . $_POST["element_2"] . " |
" . $_POST["element_2_1"] . " | " . $_POST["element_2_2"] . " | " . $_POST["element_2_3"] . " |
" . $_POST["element_3"] . " | " . $_POST["element_3_1"] . " | " . $_POST["element_3_2"] . " |
" . $_POST["element_4"]); // salvo i dati nel file
fclose($fp);
foreach(file("vostri_viaggi2.php") as $f) {
echo $f . "<br />";
}
?>
Codice PHP:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="_your description goes here_" />
<meta name="keywords" content="_your,keywords,goes,here_" />
<meta name="author" content="Luca Venturi" />
<link rel="stylesheet" type="text/css" href="loyout.css" media="screen" title="Viaggi e Miraggi" />
<link rel="stylesheet" type="text/css" href="print.css" media="print" />
<title>Viaggi & Miraggi</title>
<style type="text/css">
<!--
#wrap #avmenu ul li a {
font-size: 14px;
}
.hkl {
font-size: 14px;
}
.j {
color: #000;
}
#wrap #content form p .hkl {
text-align: left;
}
#wrap #content form p .hkl {
text-align: left;
}
-->
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<h1>Viaggi & Miraggi</h1>
<p><strong>"Didascalia"</strong><br />(traditional haiku poem)</p>
</div>
<img id="frontphoto" src="immagini\logo2.jpg" width="760" height="175" alt="" />
<div id="avmenu">
<h2 class="hide">Menu:</h2>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">Racconti di viaggio</a></li>
<li><a href="#">Viaggi & Miraggi</a></li>
<li><a href="http://fotoalbum.viaggimiraggi.it">Photo Gallery</a></li>
<li><a href="#">I vostri giudizi</a></li>
<li><a href="#">La foto più bella</a></li>
<li><a href="#">Forum</a></li>
</ul>
<div class="announce">
<h3>Ultime novità:</h3>
<p><strong>10 Ottobre 2009:</strong><br />
Il sito, nato da una delle pensate di Luca Venturi è finalmente online</p>
<p class="textright"><a href="index.html">Altro...</a></p>
</div>
</div>
<div id="extras">
<h3>More info:</h3>
<p>This is the third column, which can be used in many different ways. For example, it can be used for comments, site news, external links, ads or for more navigation links. It is all up to you!</p>
<h3>Links:</h3>
<p>- <a href="http://andreasviklund.com/">My website</a><br />
- <a href="http://oswd.org/">OSWD.org</a><br />
- <a href="http://validator.w3.org/check/referer">Valid XHTML</a><br />
- <a href="http://jigsaw.w3.org/css-validator/check/referer">Valid CSS</a></p>
</div>
<div id="content">
<h2>
<?php echo $_SESSION['titolo']; ?>
</h2>
<p>In questa sezione potrete raccontarci i vostri viaggi.</p>
<p> </p>
<form id="form_118589" class="appnitro" enctype="multipart/form-data" method="post" action="">
<div class="form_description">
<h2>I vostri viaggi</h2>
<p>Descriveteceli...</p>
<label class="description" for="element_1">Titolo
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</label>
<div>
<p>Luogo
<select class="element select medium" id="element_8" name="element_8">
<option value="" selected="selected"></option>
<option value="1" >Italia</option>
<option value="2" >Europa</option>
<option value="3" >America del Nord</option>
<option value="4" >America del Sud</option>
<option value="5" >Australia</option>
<option value="6" >Asia</option>
</select>
</p>
<div></div>
<label class="description" for="element_2">Data del Viaggio </label>
<span>
<input id="element_2_1" name="element_2_1" class="element text" size="2" maxlength="2" value="" type="text"> /
<label for="element_2_1">MM</label>
</span>
<span>
<input id="element_2_2" name="element_2_2" class="element text" size="2" maxlength="2" value="" type="text"> /
<label for="element_2_2">DD</label>
</span>
<span>
<input id="element_2_3" name="element_2_3" class="element text" size="4" maxlength="4" value="" type="text">
<label for="element_2_3">YYYY</label>
</span>
<span id="calendar_2">
<img id="cal_img_2" class="datepicker" src="calendar.gif" alt="Pick a date.">
</span>
<script type="text/javascript">
Calendar.setup({
inputField : "element_2_3",
baseField : "element_2",
displayArea : "calendar_2",
button : "cal_img_2",
ifFormat : "%B %e, %Y",
onSelect : selectDate
});
</script>
<label class="description" for="element_3"><br />
Costo </label>
<span class="symbol">€</span>
<span>
<input id="element_3_1" name="element_3_1" class="element text currency" size="10" value="" type="text" /> .
<label for="element_3_1">Euros</label>
</span>
<span>
<input id="element_3_2" name="element_3_2" class="element text" size="2" maxlength="2" value="" type="text" />
<label for="element_3_2">Cents</label>
</span>
<label class="description" for="element_4">Descrizione </label>
<div>
<textarea id="element_4" name="element_4" class="element textarea medium"></textarea>
</div>
<label class="description" for="element_5">Immagini </label>
<div>
<input id="element_5" name="element_5" class="element file" type="file"/>
</div>
<label class="description" for="element_6"> </label>
<div>
<input id="element_6" name="element_6" class="element file" type="file"/>
</div>
<label class="description" for="element_7"> </label>
<div>
<input id="element_7" name="element_7" class="element file" type="file"/>
</div>
<input type="hidden" name="form_id" value="118589" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Invia" />
</div>
</form>
</div>
<div id="footer">
<p>Copyright © 2009 Viaggi & Miraggi</p>
<p align="center"><!-- Inizio Codice Shinystat -->
<script type="text/javascript" language="JavaScript" src="http://codice.shinystat.com/cgi-bin/getcod.cgi?USER=ViaggiMiraggi"></script>
<noscript>
<a href="http://www.shinystat.com/it" target="_top"><img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=ViaggiMiraggi" alt="Statistiche" border="0" /></a>
</noscript>
<!-- Fine Codice Shinystat --><p>
</div>
</div>
</body>
</html>
Cosa sbaglio??? Non funiziona!!!