modulo.php
Codice PHP:
<?php
$cookie = $_COOKIE['accesso_effettuato'];
$username=$_POST['user'];
$password=$_POST['pass'];
$id=$_GET['id'];
if ($cookie == "accesso_effettuato")
{
//Mi connetto al db
$db = mysql_connect("localhost","AAA","AAA") or die("Connessione non riuscita: " . mysql_error());
mysql_select_db("my_razers", $db);
$query = "SELECT * FROM `news` WHERE id_news='$id'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if(!isset($id))
{header("location: errore.php"); }
else {echo ?>
<html>
<head>
<title><?php echo $row['titolo'] ?> | Razers</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div class="container">
<div class="header">
<div align="right">
[url="#"][img]img/i.jpg[/img][/url]
[url="#"][img]img/puntointerrogativo.jpg[/img][/url]
</div>
</div>
<div class="sottoheader">
<?php
include 'menutend.php'
?>
</div>
<div class="gestione_generale">
<div class="gestione_titolo">
<center>Documento: <?php echo $row['titolo']?></center>
</div>
<div class="gestione_contenuti">
[url="index.php"]Home[/url] > [url="cp.php"]Amministrazione Globale[/url] > [b]<?php echo $row['titolo']?>[/b]
<hr>
<form method="post" action="edit_dati.php" name="nuova_news">
<fieldset style="border: 1px solid #D1D1D1;"><legend>[b]Modifica il modulo:[/b]</legend>
<table>
<tr>
<td colspan="2">
Qui puoi modificare eventuali errori digitati nel modulo:
</td>
</tr>
<tr>
<td>
[b]Categoria:[/b]
</td>
<td align="right">
<select name="categoria" style="width: 200px;">
<option value="News" selected>News</option>
<option value="Avviso">Avviso</option>
</select>
</td>
<td rowspan="4" align="center">
<input type="submit" value="Salva" style="width: 120px;" />
<input type="reset" value="Resetta i campi" style="width: 120px;" />
</td>
</tr>
<tr>
<td>
[b]Titolo:[/b]
</td>
<td>
<input type="text" name="titolo" style="width: 300px;" value="<?php echo $row['titolo']?>" />
</td>
</tr>
<tr>
<td>
[b]Descrizione:[/b]
</td>
<td>
<input type="text" name="descrizione" style="width: 300px;" value="<?php echo $row['descrizione']?>" />
</td>
</tr>
<tr>
<td>
[b]Autore:[/b]
</td>
<td>
<input type="text" name="autore" style="width: 300px;" value="<?php echo $row['autore']?>" />
</td>
</tr>
<tr>
<td>
[b]Contenuto:[/b]
</td>
</tr>
<tr>
<td colspan="2">
<textarea type="text" name="contenuto" style="width: 390px; height: 100px;" /><?php echo $row['contenuto']?></textarea>
</td>
</tr>
</table>
</fieldset>
</form>
</div>
<div class="gestione_footer1">
</div>
<div class="gestione_footer2">
</div>
</div>
</body>
</html>
<?php
}
mysql_close($db);
}
else{
header("location: login.php");
}
?>
modulo.php
Codice PHP:
<?php
//Variabili prese precedentemente
$id=$_GET['id'];
$titolo = $_POST['titolo'];
$autore = $_POST['autore'];
$descrizione = $_POST['descrizione'];
$contenuto = $_POST['contenuto'];
$categoria = $_POST['categoria'];
$data_news = time();
// Connessione al db
$db = mysql_connect("localhost","AAA","AAA") or die("Connessione non riuscita: " . mysql_error());
mysql_select_db("my_razers", $db);
$query = "UPDATE news SET titolo = '$titolo', autore = '$autore', descrizione = '$descrizione', contenuto = '$contenuto', categoria = '$categoria', data_news = '$data_news' WHERE id_news='$id'";
if (mysql_query($query, $db))
{echo ?>
<html>
<head>
<title><?php echo $titolo ?> | Razers</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div class="container">
<div class="header">
<div align="right">
[url="#"][img]img/i.jpg[/img][/url]
[url="#"][img]img/puntointerrogativo.jpg[/img][/url]
</div>
</div>
<div class="sottoheader">
<?php
include 'menutend.php'
?>
</div>
<div class="gestione_generale">
<div class="gestione_titolo">
<center>Documento: <?php echo $titolo ?></center>
</div>
<div class="gestione_contenuti">
[url="index.php"]Home[/url] > [url="cp.php"]Amministrazione Globale[/url] > [b]<?php echo $titolo ?>[/b]
<hr>
<form method="post" action="gestione_dati.php" name="nuova_news">
<div class="successo">
[img]img/succes.png[/img]I dati sono stati modificati con successo!
</div>
<fieldset style="border: 1px solid #D1D1D1;"><legend>[b]Riepilogo del modulo:[/b] <?php echo $titolo ?></legend>
<table>
<tr>
<td colspan="2">
Ti preghiamo di ricontrollare i dati modificati e, se opportuno, modificarli.
</td>
</tr>
<tr>
<td>
[b]Categoria:[/b]
</td>
<td>
<?php echo $categoria ?>
</td>
</tr>
<tr>
<td>
[b]Titolo:[/b]
</td>
<td>
<?php echo $titolo ?>
</td>
</tr>
<tr>
<td>
[b]Descrizione:[/b]
</td>
<td>
<?php echo $descrizione ?>
</td>
</tr>
<tr>
<td>
[b]Autore:[/b]
</td>
<td>
<?php echo $autore ?>
</td>
</tr>
<tr>
<td>
[b]Contenuto:[/b]
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $contenuto ?>
</td>
</tr>
</table>
</fieldset>
</form>
</div>
<div class="gestione_footer1">
</div>
<div class="gestione_footer2">
</div>
</div>
</body>
</html>
<?php
}
else
{print("Errore nella modifica dei dati!");}
mysql_close($db);
?>
Per quanto riguarda date(), non mi restituisce nessun errore, ma mi salva comunque mi salva sempre 0000-00-00.