questa è la pagina:
Codice PHP:
<table>
    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
        <tr>
            <td>Title:</td>
            <td>
                <input type="text" name="title" value="guida ai css" id="txtTitle" style="width: 250px;" />
            </td>
        </tr>
        <script type="text/javascript">
            var campo = new LiveValidation('txtTitle', { validMessage: "\u221a" });
            campo.add(Validate.Presence);
        </script>
        <tr>
            <td>Author:</td>
            <td>
                <select name="author">
                    <option value="*">*</option>
                    <?php
                    
foreach (selectAuthor () as $rowAuthor) {
                        echo 
"<option value='" $rowAuthor['author_id'] . "'>" $rowAuthor['author_name'] . "</option>";
                    }
                    
?>
                </select>
            </td>
        </tr>
        <tr>
            <td>Editor:</td>
            <td>
                <select name="editor">
                    <option value="*">*</option>
                    <?php
                    
foreach (selectEditor () as $rowEditor) {
                        echo 
"<option value='" $rowEditor['editor_id'] . "'>" $rowEditor['editor_name'] . "</option>";
                    }
                    
?>
                </select>
            </td>
        </tr>
        <tr>
            <td>Price:</td>
            <td>
                <input type="text" name="price" value="0" id="txtPrice" />
            </td>
        </tr>
        <script type="text/javascript">
            var num = new LiveValidation('txtPrice', { validMessage: "\u221a" });
            num.add(Validate.Numericality);
        </script>
        <tr>
            <td>Isbn:</td>
            <td>
                <input type="text" name="isbn" value="" />
            </td>
        </tr>
        <tr>
            <td>
                Note:
            </td>
            <td>
                <textarea name="note" rows="6" cols="40">
                </textarea>
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" value="Submit" name="Submit" />
            </td>
        </tr>
    </form>
</table>

<?php
                    
if ($_SERVER['REQUEST_METHOD'] == "POST") {
                        if (
$_POST['title'] == NULL) {
                            echo 
'Insert a title';
                        } elseif (
$_POST['author'] == "*") {
                            echo 
'Insert an author';
                        } elseif (
$_POST['editor'] == "*") {
                            echo 
'Insert an editor';
                        } elseif (!
is_numeric($_POST['price'])) {
                            echo 
'Price is not a number';
                        } else {
                            try {
                                
$prepare $config->getPdo()->prepare("INSERT book (title, author_id, editor_id, price, isbn, note) VALUES (?,?,?,?,?,?)");
                                
$prepare->execute(array(
                                    
strtolower(trim($_POST['title'])),
                                    
strtolower(trim($_POST['author'])),
                                    
strtolower(trim($_POST['editor'])),
                                    
trim($_POST['price']),
                                    
strtolower(trim($_POST['isbn'])),
                                    
strtolower(trim($_POST['note']))
                                ));
                                
header('location:[url]http://localhost/book/index.php[/url]');
                            } catch (
Exception $e) {
                                die(
$e->getMessage());
                            }
                        }
                    }
dopo il submit e la conclusione della query di insert dovrebbe fare il redirect in home page.
invece ricarica la pagina e basta.
sapete il motivo??