Hallo,
ich habe ein Problem, ich möchte über meine Webseite die Daten, in der Datenbank, aktualisieren aber es geht irgendwie nicht.
Hoffe auf schnelle Hilfe.
PHP
<?php
$db = new database();
//getting values
if(isset($_POST['submit'])){
$title = mysqli_real_escape_string($db->link,$_POST['title']);
$content = mysqli_real_escape_string($db->link,$_POST['content']);
$cat = mysqli_real_escape_string($db->link,$_POST['category_id']);
$author = mysqli_real_escape_string($db->link,$_POST['author']);
$tags = mysqli_real_escape_string($db->link,$_POST['tags']);
//simple validation and query
if($title=='' || $author=='' || $tags==''){
echo "Bitte alle Felder ausfüllen!";
exit();
}
else {
$query = "INSERT INTO posts (category_id,title,content,author,tags)
values ('$cat','$title','$content,'$author','$tags')";
$insert_post = $db->insert($query);
}
}
//getting posts
$query = "SELECT * FROM categories";
$cat = $db->select($query);
?>
<form role="form" method="post" action="add_post.php">
<div class="form-group">
<label>Title</label>
<input type="text" name="title" class="form-control" placeholder="Enter title">
</div>
<div class="form-group">
<label>Inhalt</label>
<textarea name="content" class="form-control" placeholder="Enter text" ></textarea>
</div>
<div class="form-group">
<label>Kategorie</label>
<select class="form-control" name="cat">
<?php while($row=$cat->fetch_array()) :?>
<option value="<?php echo $row['id'];?>"><?php echo $row['title'];?></option>
<?php endwhile;?>
</select>
</div>
<div class="form-group">
<label>Author</label>
<input type="text" name="author" class="form-control" placeholder="Enter author">
</div>
<div class="form-group">
<label>Tags</label>
<input type="text" name="tags" class="form-control" placeholder="Enter tags">
</div>
<div>
<button type="submit" name="submit" class="btn btn-success">Hinzufügen</button>
<a href="index.php" class="btn btn-danger"/>Löschen</a>
</div><br/>
</form>
Alles anzeigen