Ho modificato un po tutto..ma sempre pagina bianca! :(
Codice PHP:
<html>
<head>
<title>Prova News</title>
<style>
body { background-color: #000; color: #fff; }
</style>
</head>
<body>
<?php
$act = $_GET['act'];
$cons = mysql_connect("mysql4.netsons.org", "davide", "mypass");
mysql_select_db("davide", $cons)
switch($act) {
// ***********************************************
case "login":
if(isset($_POST['login'])) {
$user = $_POST['username'];
$username = "davide";
$pass = $_POST['password'];
$password = "2606";
if($user == "" OR $pass == "") {
echo "<b>Errore</b>: Ci sono campi vuoti...";
} else {
if($user == $username && $pass == $password) {
/******** STRUTTURA DATABASE ********
news = id - title - text - date - author - time
********/
?>
<table>
<form name="news" action="?act=news">
<tr><td>Titolo:</td><td><input type="text" name="title" /></td></tr>
<tr><td>Testo:</td><td><textarea name="text"></textarea></td></tr>
<tr><td><input type="submit" name="aggiungi" value="Aggiungi »" /></td><td><input type="reset" name="resetbis" value="Reset" /></td></tr>
</form>
</table>
<?php
}
}
}
break;
// ***********************************************
case "news":
if(isset($_POST['aggiungi'])) {
$title = $_POST['title'];
$text = $_POST['text'];
if($title == "" OR $text == "") {
echo "<b>Errore</b>: Ci sono campi vuoti...";
}else {
/* TOGLIAMO ID, VISTO CHE E' AUTO-INCREMENT */
/*$idquery = mysql_query("SELECT id FROM news ORDER BY id DESC LIMIT 1");
$id = mysql_fetch_row($idquery);*/
$text = str_replace("<", "<", $text);
$text = str_replace(">", ">", $text);
$date = date("d/m/Y");
$author = "davide";
$time = date("H:i");
$inserisci = mysql_query("INSERT TO news(id,title,text,date,author,time) VALUES('','$title','$text','$date','$author','$time)");
if($inserisci) {
echo "<p align=\"center\"><b>News Inserita!</b></p><hr /><b>ID</b>: $id<br /><b>Titolo</b>: $title<hr />$text<hr /><b>Data</b>: $date<br /><b>Autore</b>: $author<br /><b>Ora</b>: $time";
} else {
echo "<b>Errore</b>: News non aggiunta...";
}
}
}
break;
// ***********************************************
default:
?>
<table>
<form name="login" action="?act=login">
<tr><td>Username:</td><td><input type="text" name="username" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="password" /></td></tr>
<tr><td><input type="submit" name="login" value="Login »" /></td><td><input type="reset" name="reset" value="Reset" /></tr>
</form>
</table>
<?php
break;
// ***********************************************
}
mysql_close($cons);
?>
</body>
</html>