ok posto tutto lo script,
file add-news.php (sorta di pannello con cui inviare informazioni)
Codice PHP:
<?php include 'includes/auth.inc.php'; include 'includes/db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); ?> <html> <head> <title>aggiungi articolo</title> </head> <body>
aggiungi ciò che vuoi.</p>
[url="main.php"]Click here[/url] to return to the home page.</p> <form name="form1" method="POST" action="news-added.php">
Title: <input name="title" id="title" type="text"> </p>
Tagline: <input name="tagline" id="tagline" type="text"> </p>
Section: <input name="section" id="section" type="text"> </p>
Article: <textarea name="article" cols="50" rows="6" id="article" type="text"></textarea> </p> <p align="center"> <input name="Submit" value="Submit" type="submit"> </p> </form> </body> </html>
file news-added.php (dovrebbe rielaborare le informazioni inviate da add-news.php )
Codice PHP:
<?php include 'includes/db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //passaggio variabili $title = $_POST['title']; $tagline = $_POST['tagline']; $section = $_POST['section']; $article = $_POST['article']; //continuo lo script : $article_id = mysql_insert_id($db); $query = 'INSERT INTO user_article (article_id, title, tagline, section, article) VALUES (' . $article_id . ', ' . '"' . mysql_real_escape_string($title, $db) . '", ' . '"' . mysql_real_escape_string($tagline, $db) . '", ' . '"' . mysql_real_escape_string($section, $db) . '", ' . '"' . mysql_real_escape_string($article, $db) . '", ' .'")'; $result = mysql_query($query, $db) or die(mysql_error()); echo "articolo aggiunto"; ?>
file includes/db.inc.php (dati accesso a mysql)
Codice PHP:
<?php define('MYSQL_HOST','localhost'); define('MYSQL_USER','root'); define('MYSQL_PASSWORD', '' ); define('MYSQL_DB','libro'); ?>
edit: ricevo l'errore quando clicko su submit ( add-news.php )