Salve, sto usando l'sqlite nel mio sito personale.. ora ho fatto l'inserimento senza problemi ma non so come fare il modifica ovvero il submit dei post di modifica lo fatti etc..
ma non so come fare ad far popolare il form con i dati scritti nel database.
codice:
mi date una mano per favore?
poi non so come mai inserisco i dati e il campo data è indietro di due ore.?
avete idee?
grazie mille.
buona serata.
ma non so come fare ad far popolare il form con i dati scritti nel database.
codice:
PHP:
<?php
$subject = (isset($_POST["subject"])) ? trim (($_POST["subject"])): '';
$categories = (isset($_POST["categories"])) ? trim (($_POST["categories"])): '';
$intro = (isset($_POST["intro"])) ? trim (($_POST["intro"])): '';
$content = (isset($_POST["content"])) ? trim (($_POST["content"])): '';
$is_public = (isset($_POST["is_public"])) ? trim (($_POST["is_public"])): '';
?><style>
.input {
border: 1px solid #006;
background: #ffc;
}
.input:hover {
border: 1px solid #f00;
background: #ff6;
}
.button {
margin: 20px;
padding: 4px 10px;
border: 1px solid black;
border-radius: 6px;
background-color: #ffff00;
}
.button:hover {
border: 1px solid #f00;
background: #eef;
}
label {
display: block;
width: 150px;
float: left;
margin: 2px 10px 6px 4px;
text-align: right;
}
legend{
margin: 20px;
padding: 4px 10px;
border: 1px solid black;
border-radius: 6px;
background-color: #ffff00;
}
br { clear: left; }
</style>
<?php
try {
$posts = $db->prepare('SELECT * FROM blog WHERE id:id');
$posts->bindParam(':id', $id);
$posts->execute();
} catch (Exception $e) {
die ($e);
}
?>
<form name="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
<fieldset>
<legend>Edit post</legend>
<?php
if(isset($error)){ echo "<p class=\"error\">".$error."</p>";}
if(isset($msg)){ echo $msg;} else {
?><br />
<label for="subject">Titolo:</label>
<input type="text" name="subject" value="<?php if(isset($_POST['subject'])){echo $_POST['subject'];}else { echo htmlspecialchars($subject); }?>">
<br />
<br />
<label for="categories">Categoria:</label>
Penso<input type="radio" name="categories" value="penso" <?php if($categories=='penso') echo 'checked="checked"'?> />
Scrivo<input type="radio" name="categories" value="2" <?php if($categories=='scrivo') echo 'checked="checked"'?>/>
5-Minuti<input type="radio" name="categories" value="2" <?php if($categories=='5-minuti') echo 'checked="checked"'?>/>
Laboratorio<input type="radio" name="categories" value="2" <?php if($categories=='lab') echo 'checked="checked"'?>/>
<br />
<br />
<label for="intro">Introduzione:</label>
<textarea name="intro" rows="8" cols="50"><?php if(isset($_POST['intro'])){echo $_POST['intro'];}else { echo htmlspecialchars($intro); }?></textarea>
<br />
<br />
<label for="content">Contenuto:</label>
<textarea name="content" rows="8" cols="50"><?php if(isset($_POST['content'])){echo $_POST['content'];}else { echo htmlspecialchars($content); }?></textarea>
<br />
<br />
<label for="is_public">Stato pubblicazione:</label>
On<input type="radio" name="is_public" value="1" <?php if($is_public=='1') echo 'checked="checked"'?> />
off<input type="radio" name="is_public" value="2" <?php if($is_public=='2') echo 'checked="checked"'?>/>
<br />
<br />
<label for="Password">Password:</label>
<input type="text" name="blogpass" />
<br />
<label for="invia"></label>
<input type="submit" class="button" name="submit" />
</fieldset>
</form>
<?php }
?>
mi date una mano per favore?
poi non so come mai inserisco i dati e il campo data è indietro di due ore.?
avete idee?
grazie mille.
buona serata.