Nabend
Ich habe ein für mich unlösbares Problem. Nämlich wird mir in der Error.log angezeigt das alle Variabeln die ich abfangen will, "undefined" sind. Wenn ich aber die einzelnen Variablen mit var_dump() ausgebe, steht alles drin.
Es ist ein Script zum auslesen eines Eintrags aus der DB mittels ID, diese dann bearbeiten und anschliessend updaten.
Es ist bestimmt nicht ein Script wie aus dem Lehrbuch, darum nehme ich auch gerne Verbesserungsvorschläge entgegen. In erster Linie geht es mir aber um das Problem mit den Variablen.
PS: Mir ist durchaus bewusst das ich die Felder nicht mit isset prüfe, dass ist momentan auch so gewollt.
Ich habe ein für mich unlösbares Problem. Nämlich wird mir in der Error.log angezeigt das alle Variabeln die ich abfangen will, "undefined" sind. Wenn ich aber die einzelnen Variablen mit var_dump() ausgebe, steht alles drin.
Es ist ein Script zum auslesen eines Eintrags aus der DB mittels ID, diese dann bearbeiten und anschliessend updaten.
Es ist bestimmt nicht ein Script wie aus dem Lehrbuch, darum nehme ich auch gerne Verbesserungsvorschläge entgegen. In erster Linie geht es mir aber um das Problem mit den Variablen.
PS: Mir ist durchaus bewusst das ich die Felder nicht mit isset prüfe, dass ist momentan auch so gewollt.
PHP:
<?php
/*Fetch data from Anime which is selected from the List *
*Select data with the Anime-id given in a *
*Update the data in the db ONLY FOR TEAM-MEMBER *
*Code by: lauder@jpanimes.net *
*Last update: 2013.10.12 20:17 +0000 */
$con = new mysqli ('host', 'dbuser' ,'pw' , 'db');
$a = $_GET['a'];
//Select everything from anime where ID is in
$result = $con->query("SELECT * FROM anime WHERE id = '$a'");
while($row = $result->fetch_assoc()) {
$output[] = $row;
}
?>
<form method="post" action="<?php ($_SERVER["PHP_SELF"]);?>">
<table>
<tr><td><?php echo 'Titel:' . $output[0]['original_title'];?></td></tr>
<tr><td width="100">Originaltitel:</td><td><input type="text" name="original_title" value="<?php echo htmlspecialchars($output[0]['original_title']);?>"></td></tr>
<tr><td width="100">Japanischer Titel:</td><td><input type="text" name="japan_title" value="<?php echo htmlspecialchars($output[0]['japan_title']);?>"></td></tr>
<tr><td width="100">Englischer Titel:</td><td><input type="text" name="english_title" value="<?php echo htmlspecialchars($output[0]['english_title']);?>"></td></tr>
<tr><td width="100">Studio</td><td><input type="text" name="studio" value="<?php echo htmlspecialchars($output[0]['studio']);?>"></td></tr>
<tr><td widht="100">Anzahl Episoden:</td><td><?php echo '1111';?></td></tr>
<tr>
<td width="100">Status:</td>
<td>
<select name="status" size="1">
<?php if($output[0]['state'] == 1){echo '<option value="1" selected>Freigegeben</option>';}
else {echo '<option value="1">Freigegeben</option>';}?>
<?php if($output[0]['state'] == 0){echo '<option value="0" selected>Gesperrt</option>';}
else {echo '<option value="0">Gesperrt</option>';}?>
</select>
</td>
</tr>
<tr>
<td>Saison</td>
<td>
<select name="season" size="1">
<?php if($output[0]['season'] == 'Winter'){echo '<option value="Winter" selected>Winter</option>';}
else {echo '<option value="Winter">Winter</option>';}
if($output[0]['season'] == 'Frühling'){echo '<option value="Fruehling" selected>Frühling</option>';}
else {echo '<option value="Fruehling">Frühling</option>';}
if($output[0]['season'] == 'Sommer'){echo '<option value="Sommer" selected>Sommer</option>';}
else {echo '<option value="Sommer">Sommer</option>';}
if($output[0]['season'] == 'Herbst'){echo '<option value="Herbst" selected>Herbst</option>';}
else {echo '<option value="Herbst">Herbst</option>';}?>
</select>
</td>
</tr>
<tr>
<td>Jahr</td>
<td>
<select name="year" size="1">
<?php
$i = 1985;
do {
if($output[0]['year'] == $i){echo '<option value="' . $i . '" selected>' . $i . '</option>';}
else {echo '<option value="' . $i . '">' . $i . '</option>';}
$i++;
} while ($i != 2014);
?>
</select>
</td>
</tr>
</table>
<table>
<tr width="100">
<?php
if (strpos($output[0]['genres'], "Abenteuer") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Abenteuer">Abenteuer</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Abenteuer" checked>Abenteuer</td>';}
if (strpos($output[0]['genres'], "Action") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Action">Action</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Action" checked>Action</td>';}
if (strpos($output[0]['genres'], "Adult") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Adult">Adult</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Adult" checked>Adult</td>';}
if (strpos($output[0]['genres'], "Comedy") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Comedy">Comedy</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Comedy" checked>Comedy</td>';}
if (strpos($output[0]['genres'], "Cyberpunk") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Cyberpunk">Cyberpunk</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Cyberpunk" checked>Cyberpunk</td>';}
if (strpos($output[0]['genres'], "Drama") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Drama">Drama</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Drama" checked>Drama</td>';}
if (strpos($output[0]['genres'], "Ecchi") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Ecchi">Ecchi</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Ecchi" checked>Ecchi</td>';}
if (strpos($output[0]['genres'], "Fantasy") === false){echo '<td width="8%"><input type="checkbox" name="genres[]" value="Fantasy">Fantasy</td>';}
else {echo '<td width="8%"><input type="checkbox" name="genres[]" value="Fantasy" checked>Fantasy</td>';}
if (strpos($output[0]['genres'], "Harem") === false){echo '<td width="18%"><input type="checkbox" name="genres[]" value="Harem">Harem</td>';}
else {echo '<td width="18%"><input type="checkbox" name="genres[]" value="Harem" checked>Harem</td>';}
?>
</tr>
<tr>
<?php
if (strpos($output[0]['genres'], "Historical") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Historical">Historical</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Historical" checked>Historical</td>';}
if (strpos($output[0]['genres'], "Horror") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Horror">Horror</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Horror" checked>Horror</td>';}
if (strpos($output[0]['genres'], "Josei") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Josei">Josei</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Josei" checked>Josei</td>';}
if (strpos($output[0]['genres'], "Magic") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Magic">Magic</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Magic" checked>Magic</td>';}
if (strpos($output[0]['genres'], "Martial_Art") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Martial_Art">Martial_Art</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Martial_Art" checked>Martial_Art</td>';}
if (strpos($output[0]['genres'], "Mecha") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Mecha">Mecha</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Mecha" checked>Mecha</td>';}
if (strpos($output[0]['genres'], "Military") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Military">Military</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Military" checked>Military</td>';}
if (strpos($output[0]['genres'], "Musik") === false){echo '<td width="8%"><input type="checkbox" name="genres[]" value="Musik">Musik</td>';}
else {echo '<td width="8%"><input type="checkbox" name="genres[]" value="Musik" checked>Musik</td>';}
if (strpos($output[0]['genres'], "Mystery") === false){echo '<td width="18%"><input type="checkbox" name="genres[]" value="Mystery">Mystery</td>';}
else {echo '<td width="18%"><input type="checkbox" name="genres[]" value="Mystery" checked>Mystery</td>';}
?>
</tr>
<tr>
<?php
if (strpos($output[0]['genres'], "Psychological") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Psychological">Psychological</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Psychological" checked>Psychological</td>';}
if (strpos($output[0]['genres'], "Romance") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Romance">Romance</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Romance" checked>Romance</td>';}
if (strpos($output[0]['genres'], "SciFi") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="SciFi">SciFi</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="SciFi" checked>SciFi</td>';}
if (strpos($output[0]['genres'], "Seinen") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Seinen">Seinen</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Seinen" checked>Seinen</td>';}
if (strpos($output[0]['genres'], "Shoujou") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Shoujou">Shoujou</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Shoujou" checked>Shoujou</td>';}
if (strpos($output[0]['genres'], "Shoujou_Ai") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Shoujou_Ai">Shoujou_Ai</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Shoujou_Ai" checked>Shoujou_Ai</td>';}
if (strpos($output[0]['genres'], "Shounen") === false){echo '<td width="8%"><input type="checkbox" name="genres[]" value="Shounen">Shounen</td>';}
else {echo '<td width="8%"><input type="checkbox" name="genres[]" value="Shounen" checked>Shounen</td>';}
if (strpos($output[0]['genres'], "Shounen_Ai") === false){echo '<td width="18%"><input type="checkbox" name="genres[]" value="Shounen">Shounen_Ai</td>';}
else {echo '<td width="18%"><input type="checkbox" name="genres[]" value="Shounen_Ai" checked>Shounen_Ai</td>';}
?>
</tr>
<tr>
<?php
if (strpos($output[0]['genres'], "Slice_of_Life") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Slice_of_Life">Slice of Life</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Slice_of_Life" checked>Slice of Life</td>';}
if (strpos($output[0]['genres'], "Splatter") === false){echo '<td width="12%"><input type="checkbox" name="genres[]" value="Splatter">Splatter</td>';}
else {echo '<td width="12%"><input type="checkbox" name="genres[]" value="Splatter" checked>Splatter</td>';}
if (strpos($output[0]['genres'], "Sport") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Sport">Sport</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Sport" checked>Sport</td>';}
if (strpos($output[0]['genres'], "Superpower") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Superpower">Superpower</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Superpower" checked>Superpower</td>';}
if (strpos($output[0]['genres'], "Vampire") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Vampire">Vampire</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Vampire" checked>Vampire</td>';}
if (strpos($output[0]['genres'], "Violence") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Violence">Violence</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Violence" checked>Violence</td>';}
if (strpos($output[0]['genres'], "Yaoi") === false){echo '<td width="10%"><input type="checkbox" name="genres[]" value="Yaoi">Yaoi</td>';}
else {echo '<td width="10%"><input type="checkbox" name="genres[]" value="Yaoi" checked>Yaoi</td>';}
if (strpos($output[0]['genres'], "Yuri") === false){echo '<td width="8%"><input type="checkbox" name="genres[]" value="Yuri">Yuri</td>';}
else {echo '<td width="8%"><input type="checkbox" name="genres[]" value="Yuri" checked>Yuri</td>';}
?>
</tr>
</table>
<table>
<tr>
<?php
if (strpos($output[0]['manifestations'], "Serie") === false){echo '<td width="12%"><input type="checkbox" name="manif[]" value="Serie">Serie</td>';}
else {echo '<td width="12%"><input type="checkbox" name="manif[]" value="Serie" checked>Serie</td>';}
if (strpos($output[0]['manifestations'], "OVA_Special") === false){echo '<td width="12%"><input type="checkbox" name="manif[]" value="OVA_Special">OVA/Special</td>';}
else {echo '<td width="12%"><input type="checkbox" name="manif[]" value="OVA_Special" checked>OVA/Special</td>';}
if (strpos($output[0]['manifestations'], "Movie") === false){echo '<td width="12%"><input type="checkbox" name="manif[]" value="Movie">Movie</td>';}
else {echo '<td width="12%"><input type="checkbox" name="manif[]" value="Movie" checked>Movie</td>';}
if (strpos($output[0]['manifestations'], "Manga") === false){echo '<td width="12%"><input type="checkbox" name="manif[]" value="Manga">Manga</td>';}
else {echo '<td width="12%"><input type="checkbox" name="manif[]" value="Manga" checked>Manga</td>';}
if (strpos($output[0]['manifestations'], "Game") === false){echo '<td width="12%"><input type="checkbox" name="manif[]" value="Game">Game</td>';}
else {echo '<td width="12%"><input type="checkbox" name="manif[]" value="Game" checked>Game</td>';}
?>
</tr>
</table>
<table>
<textarea maxlenght="2000" rows="5" cols="70" name="description"><?php echo htmlspecialchars($output[0]['description']);?></textarea>
<input type="submit" value="Bearbeiten">
</table>
<?php
htmlspecialchars ($otitle = $_POST['original_title']);
htmlspecialchars ($jtitle = $_POST['japan_title']);
htmlspecialchars ($etitle = $_POST['english_title']);
htmlspecialchars ($studio = $_POST['studio']);
htmlspecialchars ($status = $_POST['status']);
htmlspecialchars ($season = $_POST['season']);
htmlspecialchars ($year = $_POST['year']);
htmlspecialchars ($des = $_POST['description']);
/*Genres auslesen*/
$genres = "";
foreach ($_POST['genres'] as $id) {
$genres .= $id . " ";
}
/*Manifestationen auslesen*/
$manif = "";
foreach ($_POST['manif'] as $ma) {
$manif .= $ma . " ";
}
$con->query("UPDATE anime SET
original_name = '$otitle',
japan_title = '$jtitle',
english_title = '$etitle',
genres = '$genres',
studio = '$studio',
season = '$season',
year = '$year',
state = '$status',
manifestations = '$manif',
description = '$des' WHERE id = '$a'");
?>