RedlightX
Bekannter NGBler
- Registriert
- 18 Juli 2013
- Beiträge
- 1.185
Hallo zusammen,
ich möchte eine kleine Webanwendung zur Comicverwaltung schreiben, die auf meinem NAS abgelegt wird.
Um einen neuen Datensatz anzulegen, nutze ich ein Modal. Die eingetragenen Daten sollen dann in einer Datenbank abgespeichert werden. - Allerdings liegt genau da das Problem -> Sie werden nicht gespeichert
[src=html5]
<!-- Modal -->
<div class="modal fade" id="newcomic" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="form" method="post">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">
Neuen Comic hinzufügen
</h4>
</div>
<div class="modal-body">
<form action="addcomic.php">
<div class="form-group">
<label for="inputTitle">Titel</label>
<input type="text" class="form-control" name="inputTitle" id="inputTitle" placeholder="Titel eingeben">
</div>
<div class="form-group">
<label for="inputSeries">Serie</label>
<input type="text" class="form-control" name="inputSeries "id="inputSeries" placeholder="Serie eingeben">
</div>
<div class="form-group">
<label for="inputNumber">Nummer</label>
<input type="text" class="form-control" name="inputNumber" id="inputNumber" placeholder="Nummer des Comics eingeben">
</div>
<div class="form-group">
<label for="inputRelease">Erscheinungsjahr</label>
<input type="text" class="form-control" name="inputRelease "id="inputRelease" placeholder="Erscheinungsjahr eingeben">
</div>
<div class="form-group">
<label for="inputPublisher">Verlag</label>
<input type="text" class="form-control" name="inputPublisher" id="inputPublisher" placeholder="Verlag eingeben">
</div>
<div class="form-group">
<label for="inputBookcondition">Zustand</label>
<input type="text" class="form-control" name="inputBookcondition" id="inputBookcondition" placeholder="Zustand eingeben">
</div>
<div class="form-group">
<label for="inputPrice">Preis</label>
<input type="text" class="form-control" name="inputPrice" id="inputPrice" placeholder="Preis eingeben">
</div>
<div class="form-group">
<label for="inputImage">Bild hochladen</label>
<input type="file" name="inputImage" id="inputImage">
</div>
<div class="form-group">
<label for="inputNotes">Notizen</label>
<input type="text" class="form-control" name="inputNotes "id="inputNotes" placeholder="Notizen eingeben">
</div>
<button type="button" class="btn btn-danger" data-dismiss="modal">Abbrechen</button>
<button type="submit" name="submit" id="submit" class="btn btn-success" value="submit">In Datenbank speichern</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->[/src]
Beim Absenden, soll die addcomic.php die Daten entsprechend weiterverarbeiten und sie dann in die Datenbank ablegen...
[src=php]<?php
//Variablen
$inputTitle = $POST['inputTitle'];
$inputSeries = $POST['inputSeries'];
$inputNumber = $POST['inputNumber'];
$inputRelease = $POST['inputRelease'];
$inputPublisher = $POST['inputPublisher'];
$inputBookcondition = $POST['inputBookcondition'];
$inputPrice = $POST['inputPrice'];
$inputImage = $POST['inputImage'];
$inputNotes = $POST['inputNotes'];
//DB
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "comics";
if(isset($_POST["submit"]) == "submit")
{
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO comic (title, series, comicnumber, yearpublished, publisher, bookcondition, price, image, notes) VALUES (:inputTitle,:inputSeries,:inputNumber,:inputRelease,:inputPublisher,:inputBookcondition,:inputPrice,:inputImage,:inputNotes)";
// use exec() because no results are returned
$conn->exec($sql);
echo "New record created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
}
?>[/src]
Ich bin echt ratlos und habe auch schon das Web durchforstet
ich möchte eine kleine Webanwendung zur Comicverwaltung schreiben, die auf meinem NAS abgelegt wird.
Um einen neuen Datensatz anzulegen, nutze ich ein Modal. Die eingetragenen Daten sollen dann in einer Datenbank abgespeichert werden. - Allerdings liegt genau da das Problem -> Sie werden nicht gespeichert
[src=html5]
<!-- Modal -->
<div class="modal fade" id="newcomic" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="form" method="post">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">
Neuen Comic hinzufügen
</h4>
</div>
<div class="modal-body">
<form action="addcomic.php">
<div class="form-group">
<label for="inputTitle">Titel</label>
<input type="text" class="form-control" name="inputTitle" id="inputTitle" placeholder="Titel eingeben">
</div>
<div class="form-group">
<label for="inputSeries">Serie</label>
<input type="text" class="form-control" name="inputSeries "id="inputSeries" placeholder="Serie eingeben">
</div>
<div class="form-group">
<label for="inputNumber">Nummer</label>
<input type="text" class="form-control" name="inputNumber" id="inputNumber" placeholder="Nummer des Comics eingeben">
</div>
<div class="form-group">
<label for="inputRelease">Erscheinungsjahr</label>
<input type="text" class="form-control" name="inputRelease "id="inputRelease" placeholder="Erscheinungsjahr eingeben">
</div>
<div class="form-group">
<label for="inputPublisher">Verlag</label>
<input type="text" class="form-control" name="inputPublisher" id="inputPublisher" placeholder="Verlag eingeben">
</div>
<div class="form-group">
<label for="inputBookcondition">Zustand</label>
<input type="text" class="form-control" name="inputBookcondition" id="inputBookcondition" placeholder="Zustand eingeben">
</div>
<div class="form-group">
<label for="inputPrice">Preis</label>
<input type="text" class="form-control" name="inputPrice" id="inputPrice" placeholder="Preis eingeben">
</div>
<div class="form-group">
<label for="inputImage">Bild hochladen</label>
<input type="file" name="inputImage" id="inputImage">
</div>
<div class="form-group">
<label for="inputNotes">Notizen</label>
<input type="text" class="form-control" name="inputNotes "id="inputNotes" placeholder="Notizen eingeben">
</div>
<button type="button" class="btn btn-danger" data-dismiss="modal">Abbrechen</button>
<button type="submit" name="submit" id="submit" class="btn btn-success" value="submit">In Datenbank speichern</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->[/src]
Beim Absenden, soll die addcomic.php die Daten entsprechend weiterverarbeiten und sie dann in die Datenbank ablegen...
[src=php]<?php
//Variablen
$inputTitle = $POST['inputTitle'];
$inputSeries = $POST['inputSeries'];
$inputNumber = $POST['inputNumber'];
$inputRelease = $POST['inputRelease'];
$inputPublisher = $POST['inputPublisher'];
$inputBookcondition = $POST['inputBookcondition'];
$inputPrice = $POST['inputPrice'];
$inputImage = $POST['inputImage'];
$inputNotes = $POST['inputNotes'];
//DB
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "comics";
if(isset($_POST["submit"]) == "submit")
{
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO comic (title, series, comicnumber, yearpublished, publisher, bookcondition, price, image, notes) VALUES (:inputTitle,:inputSeries,:inputNumber,:inputRelease,:inputPublisher,:inputBookcondition,:inputPrice,:inputImage,:inputNotes)";
// use exec() because no results are returned
$conn->exec($sql);
echo "New record created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
}
?>[/src]
Ich bin echt ratlos und habe auch schon das Web durchforstet