a che serve, mi sembra non sia utile alla gestione dei film ....
per la trama, in questo modo viene formattata in modo corretto
se prendo i dati da un sito (imdb) faccio copia e incolla e viene come l'originale
a che serve, mi sembra non sia utile alla gestione dei film ....
$opt .= "<option" . $selected . " value='" . $i . "'>" . $incollection[$i] . "</option>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title><?php echo $set['Title']; ?></title>
</head>
<body <?php echo $set['FirstField']; ?>>
<div class='form-group'>
<center><h1><span class='infoblock-pagetype'>inserisci dati</span></h1></center>
<form name='filmForm' method='POST' action='<?php echo $set['script']; ?>'>
<table id='biographyTable' border='0' cellspacing='0' cellpadding='0' width='100%'>
<tbody>
<tr>
<td class='paramname'>
<b>Title:</b>
</td>
<td class='paramvalue'>
<input type='text' name='movie_title' id='movie_title' size='100' value='<?php echo $row['movie_title']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Also Known As:</b>
</td>
<td class='paramvalue'>
<textarea name='also_known' id='also_known' size='50' style='width: 98%' value='<?php echo $row['also_known']; ?>'></textarea>
</td>
</tr>
<tr>
<td class='paramname'>
<b>Year: </b>
</td>
<td class='paramvalue'>
<input type='text' name='year' id='year' size='10' value='<?php echo $row['year']; ?>' />
</td>
</tr>
<tr>
<tr>
<td class='paramname'>
<b>Minutes: </b>
</td>
<td class='paramvalue'>
<input type='text' name='minutes' id='minutes' size='10' value='<?php echo $row['minutes']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Distributor: </b>
</td>
<td class='paramvalue'>
<input type='text' name='distributor' id='distributor' size='100' value='<?php echo $row['distributor']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Studio: </b>
</td>
<td class='paramvalue'>
<input type='text' name='studio' id='studio' size='100' value='<?php echo $row['studio']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Release Date: </b>
</td>
<td class='paramvalue'>
<input type='text' name='release_data' id='release_data' size='15' value='<?php echo $row['release_data']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>In Collection: </b> (<b><font color='red'>selezionare il valore</font></b>)
</td>
<td class='paramvalue'>
<select name='incollection', id='incollection'><?php echo $opt; ?></select>
</td>
</tr>
<tr>
<td class='paramname'>
<b>Synopsis: </b>
</td>
<td class='paramvalue'>
<textarea name='synopsis' id='editor1' rows='10' cols='80' value='<?php echo $row['synopsis']; ?>'></textarea>
</td>
</tr>
<!--
<tr>
<td class='paramname'>
<b>Status:</b> (<b><font color='red'>Active, Retired, Dead</font></b>)
</td>
<td class='paramvalue'>
<input type='text' name='status' id='status' value='<?php echo $row['status']; ?>' />
</td>
</tr>
-->
<tr>
<td class='paramvalue-footer center' colspan='2'>
<br />
<input type='submit' name='inserisci' id='inserisci' value='inserisci'>
<br />
<br />
</td>
</tr>
</tbody>
</table>
</form>
<div class='col-sm-10 col-sm-offset-2'><h2><?php echo $message; ?></h2></div>
</div>
</body>
</html>
<?php
}
?>
lo script é chiamato dopo un submit
lo script é chiamato per un nuovo inserimento
<tr>
<td class='paramname'>
<b>Synopsis: </b>
</td>
<td class='paramvalue'>
<textarea name='synopsis' id='editor1' rows='10' cols='80' value='<?php echo $row['synopsis']; ?>'></textarea>
</td>
</tr>
<!-- ckeditor(se ne metti piu di uno cambia textarea type="text" id="xxxxxxx" e replace('xxxxxxx', ) -->
<script src="ckeditor/ckeditor.js"></script>
<script>
CKEDITOR.replace('editor1', {
extraPlugins: 'colorbutton,colordialog'
});
</script>
sono echo inseriti nel codice per farti capire la strada che fa, puoi commentarli entrambima se faccio un refresh della pagina i dati trasmessi non spariscono, rimane questo
ho inserito il CKeditor, ma i dati non vengono passati nella query
<?php
$set['script'] = $_SERVER['PHP_SELF'];
$set['Title'] = "I miei film";
$set['FirstField'] = "onload='document.filmForm.movie_title.focus()'";
$message = "";
if (empty($_POST))
{
inizializzaVariabili(); // lo script é allo stato iniziale o al termine di una azione
}
else
{
leggiPost(); // lo script é chiamato dopo un submit
validaForm();
if ( empty($message) ) aggiornaDB($row['azione']);
}
displayForm($row['azione']);
die;
function inizializzaVariabili()
{
global $row;
$row['azione'] = "";
$row['filmID'] = "";
$row['movie_title'] = "";
$row['also_known'] = "";
$row['year'] = "";
$row['minutes'] = "";
$row['distributor'] = "";
$row['studio'] = "";
$row['release_data'] = "";
$row['incollection'] = "0";
$row['synopsis'] = "";
}
function leggiPost()
{
global $row;
$row['azione'] = addslashes($_POST['submit']);
$row['filmID'] = addslashes($_POST['filmID']);
$row['movie_title'] = addslashes($_POST['movie_title']);
$row['also_known'] = addslashes($_POST['also_known']);
$row['year'] = addslashes($_POST['year']);
$row['minutes'] = addslashes($_POST['minutes']);
$row['distributor'] = addslashes($_POST['distributor']);
$row['studio'] = addslashes($_POST['studio']);
$row['release_data'] = addslashes($_POST['release_data']);
$row['incollection'] = addslashes($_POST['incollection']);
$row['synopsis'] = addslashes($_POST['synopsis']);
}
function validaForm()
{
global $row, $message;
// qui vanno fatti i controlli dei dati inseriti
if( $row['azione'] != "inserisci"
and $row['azione'] != "modifica"
and $row['azione'] != "elimina"
and $row['azione'] != "cerca" )
{
$message = "ERRORE : non riconosco l'azione da compiere";
return;
}
if( $row['azione'] == "cerca" and empty($row['filmID']) )
{
$row['azione'] = "";
$message = "ERRORE : devi indicare il file ID";
return;
}
// $message = "NON HO FATTO ALTRI CONTROLLI";
}
function aggiornaDB($azione = "")
{
global $row, $message;
// qui si aggiorna il db,
// 1) apre la connessione
// 2) inserisce/modifica il film
// 3) verifica che sia stato inserito/aggiornato il film
// 4) chiude la connessione
switch ($azione)
{
case "inserisci":
$sql = "INSERT INTO film(movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis) VALUES ("
. " '" . $row['movie_title'] . "'"
. ", '" . $row['also_known'] . "'"
. ", '" . $row['year'] . "'"
. ", '" . $row['minutes'] . "'"
. ", '" . $row['distributor'] . "'"
. ", '" . $row['studio'] . "'"
. ", '" . $row['release_data'] . "'"
. ", '" . $row['incollection'] . "'"
. ", '" . $row['synopsis'] . "'"
. " )";
break;
case "modifica":
$sql = "UPDATE film SET"
. " movie_title='" . $row['movie_title'] . "'"
. ", also_known='" . $row['also_known'] . "'"
. ", year='" . $row['year'] . "'"
. ", minutes='" . $row['minutes'] . "'"
. ", distributor='" . $row['distributor'] . "'"
. ", studio='" . $row['studio'] . "'"
. ", release_data='" . $row['release_data'] . "'"
. ", incollection='" . $row['incollection'] . "'"
. ", synopsis='" . $row['synopsis'] . "'"
. " WHERE filmID='" . $row['filmID'] . "'";
break;
case "elimina":
$sql = "DELETE FROM film"
. " WHERE filmID='" . $row['filmID']. "'";
break;
case "cerca":
$sql = "SELECT filmID, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
. " WHERE filmID='" . $row['filmID'] . "'";
$row['filmID'] = "1"; // simula la lettura del database valorizzado l'array $row
$row['movie_title'] = "movie_title";
$row['also_known'] = "also_known";
$row['year'] = "year";
$row['minutes'] = "minutes";
$row['distributor'] = "distributor";
$row['studio'] = "studio";
$row['release_data'] = "release_data";
$row['incollection'] = "1";
$row['synopsis'] = "synopsis";
echo $sql . "<br />";
return;
break;
default:
$message = "ERRORE : aggiornaDB azione non riconosciuta";
break;
}
echo $sql . "<br />";
$query = 1; //$query = mysql_query( $sql );
if( $query )
{
inizializzaVariabili();
$message = "Congratulazioni! Dati inseriti.";
}
else
{
$message = "Attenzione : Dati non inseriti!";
}
}
function displayForm($azione = "")
{
global $row, $set, $message;
// gestisci bottoni
if ( $azione == "cerca" )
{
$btn = "<input type='submit' name='submit' value='modifica' />"
. "<input type='submit' name='submit' value='elimina' />";
}
else
{
$btn = "<input type='submit' name='submit' value='inserisci' />"
. "<input type='submit' name='submit' value='cerca' />";
}
// valorizza la select "incollection"
$opt = "";
$incollection = array( 0 => 'scegli uno stato', 1 => 'Yes', 2 => 'No' ); // possible options for career status
for( $i=0; $i < count($incollection); $i++ )
{
$selected = $i == $row['incollection'] ? ' selected' : '';
$opt .= "<option" . $selected . " value='" . $i . "'>" . $incollection[$i] . "</option>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title><?= $set['Title']; ?></title>
</head>
<body <?= $set['FirstField']; ?>>
<div class='form-group'>
<center><h1><span class='infoblock-pagetype'>inserisci dati</span></h1></center>
<form name='filmForm' method='POST' action='<?= $set['script']; ?>'>
<table id='biographyTable' border='0' cellspacing='0' cellpadding='0' width='100%'>
<tbody>
<tr>
<td class='paramname'>
<b>film ID:</b>
</td>
<td class='paramvalue'>
<input type='text' name='filmID' id='filmID' size='10' value='<?= $row['filmID']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Title:</b>
</td>
<td class='paramvalue'>
<input type='text' name='movie_title' id='movie_title' size='100' value='<?= $row['movie_title']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Also Known As:</b>
</td>
<td class='paramvalue'>
<textarea name='also_known' id='also_known' size='50' style='width: 98%'><?= $row['also_known']; ?></textarea>
</td>
</tr>
<tr>
<td class='paramname'>
<b>Year: </b>
</td>
<td class='paramvalue'>
<input type='text' name='year' id='year' size='10' value='<?= $row['year']; ?>' />
</td>
</tr>
<tr>
<tr>
<td class='paramname'>
<b>Minutes: </b>
</td>
<td class='paramvalue'>
<input type='text' name='minutes' id='minutes' size='10' value='<?= $row['minutes']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Distributor: </b>
</td>
<td class='paramvalue'>
<input type='text' name='distributor' id='distributor' size='100' value='<?= $row['distributor']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Studio: </b>
</td>
<td class='paramvalue'>
<input type='text' name='studio' id='studio' size='100' value='<?= $row['studio']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>Release Date: </b>
</td>
<td class='paramvalue'>
<input type='text' name='release_data' id='release_data' size='15' value='<?= $row['release_data']; ?>' />
</td>
</tr>
<tr>
<td class='paramname'>
<b>In Collection: </b> (<b><font color='red'>selezionare il valore</font></b>)
</td>
<td class='paramvalue'>
<select name='incollection', id='incollection'><?= $opt; ?></select>
</td>
</tr>
<tr>
<td class='paramname'>
<b>Synopsis: </b>
</td>
<td class='paramvalue'>
<textarea name='synopsis' id='editor1' rows='10' cols='80'><?= $row['synopsis']; ?></textarea>
</td>
</tr>
<!--
<tr>
<td class='paramname'>
<b>Status:</b> (<b><font color='red'>Active, Retired, Dead</font></b>)
</td>
<td class='paramvalue'>
<input type='text' name='status' id='status' value='<?= $row['status']; ?>' />
</td>
</tr>
-->
<tr>
<td class='paramvalue-footer center' colspan='2'>
<br />
<?= $btn; ?>
<br />
<br />
</td>
</tr>
</tbody>
</table>
</form>
<div class='col-sm-10 col-sm-offset-2'><h2><?= $message; ?></h2></div>
</div>
<script src="https://cdn.ckeditor.com/ckeditor5/18.0.0/classic/ckeditor.js"></script>
<script> CKEDITOR.replace('editor1', { extraPlugins: 'colorbutton,colordialog' });</script>
</body>
</html>
<?php
}
?>
function aggiornaDB($azione = "")
{
global $row, $message;
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_errno) { $message = "ERRORE : connessione al db fallita, " . $conn->connect_error; return; }
switch ($azione)
{
case "inserisci":
$sql = "INSERT INTO film(movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis) VALUES ("
. " '" . $row['movie_title'] . "'"
. ", '" . $row['also_known'] . "'"
. ", '" . $row['year'] . "'"
. ", '" . $row['minutes'] . "'"
. ", '" . $row['distributor'] . "'"
. ", '" . $row['studio'] . "'"
. ", '" . $row['release_data'] . "'"
. ", '" . $row['incollection'] . "'"
. ", '" . $row['synopsis'] . "'"
. " )";
break;
case "modifica":
$sql = "UPDATE film SET"
. " movie_title='" . $row['movie_title'] . "'"
. ", also_known='" . $row['also_known'] . "'"
. ", year='" . $row['year'] . "'"
. ", minutes='" . $row['minutes'] . "'"
. ", distributor='" . $row['distributor'] . "'"
. ", studio='" . $row['studio'] . "'"
. ", release_data='" . $row['release_data'] . "'"
. ", incollection='" . $row['incollection'] . "'"
. ", synopsis='" . $row['synopsis'] . "'"
. " WHERE filmID='" . $row['filmID'] . "'";
break;
case "elimina":
$sql = "DELETE FROM film"
. " WHERE filmID='" . $row['filmID']. "'";
break;
case "cerca":
$sql = "SELECT filmID, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
. " WHERE filmID='" . $row['filmID'] . "'";
break;
default:
$message = "ERRORE : aggiornaDB azione non riconosciuta";
return;
break;
}
echo $sql . "<br />";
if ( !$conn->query($sql) ) { $message = "ERRORE : aggiornaDB errore nella query, " . $conn->error; return; }
if ($azione == "cerca")
{
$row = $conn->fetch_assoc();
}
else
{
inizializzaVariabili();
$message = "Congratulazioni, il database é stato aggiornato.";
}
$conn->close();
}
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'exadmin'@'localhost' (using password: NO) in E:\OSPanel\domains\localhost\cinema\00inserisci_film.php on line 95
INSERT INTO film(movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis) VALUES ( 'Test movie per Alex 2', '', '', '', '', '', '', '0', 'test' )
$conn = new mysqli($host, $user, $password, $db);
ERRORE : aggiornaDB errore nella query, Duplicate entry 'Test movie per Alex 2-0000' for key 'unique_index'
ACCESSO NEGATO, per quell'utente, non é un problema dello script ...Access denied for user 'exadmin'@'localhost' (
deve essere inserito il controllo nella function validaForm, qual'é la colonna su cui vi é la chiave univoca ?ERRORE : aggiornaDB errore nella query, Duplicate entry 'Test movie per Alex 2-0000' for key 'unique_index'
é la chiave su cui viene fatta la ricerca per poi andare in modifica o eliminazionenon ho capito il campo film_id in alto, cosa serve?
io non sono davanti al tuo pc, se mi dici perché non va posso cercare di capireaggiornato, ma la ricerca per id non va'
case "cerca":
$sql = "SELECT film_id, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
. " WHERE film_id='" . $row['film_id'] . "'";
$sql = "SELECT FROM Film
$sql = "SELECT * FROM 'film' film_id, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
. " WHERE film_id='" . $row['film_id'] . "'";
case "cerca":
$sql = "SELECT * FROM film"
. " WHERE film_id='" . $row['film_id'] . "'";
break;
SELECT * FROM film WHERE film_id='508'
Fatal error: Call to undefined method mysqli::fetch_assoc() in E:\OSPanel\domains\localhost\cinema\archivioFilm.php on line 165
$row = $conn->fetch_assoc();