Non capisco come faccio mi ero già letto quel pezzo ma non fare mi aiuti
Non capisco come faccio mi ero già letto quel pezzo ma non fare mi aiuti
posta il pezzo di codice relativo al form e io ti faccio tutto il resto...![]()
I'm your dreams, make you real... I'm your eyes when you must steel...I'm pain when you can't feel...sad but true !
Eccolo
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> Titolo: <input type=TEXT> Testo per la News: <textarea name=news" rows=10 cols=60> </textarea> </body> </html>
Questo ops
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Invio News</title> </head> <body> Titolo: <input type=TEXT> Testo per la News: <textarea name=news" rows=10 cols=60> </textarea> <input type="submit" value="Invia"> <input type="reset"> </body> </html>
questo non è un form...![]()
![]()
devi fare così:
<form method="post" action="aggiungi.php">
Titolo:
<input type="text" size="30" name="titolo">
Testo per la News:
<textarea name="news" rows=10 cols=60>
</textarea>
<input type="submit" value="Invia">
</form>
poi crei un file chiamato aggiungi.php... però prima di passare a questa fase... hai creato la tabella delle news ? se la risposta è no (come immagino) prima bisogna fare quello... e per poter fare tutto ciò è necessario configurare il db (tramite CPanel) e creare un utente... è chiaro che questo non lo posso fare io via forum...
I'm your dreams, make you real... I'm your eyes when you must steel...I'm pain when you can't feel...sad but true !
La tabella lo creata nel db in locale ed ho chiamato il database News e la tabella news ok??
il codice da mettere in aggiungi.php è:
$db_host = "localhost";
$db_user = "****tuo username ****";
$db_password = "**** tua password ****";
$db_name = "**** nome del db ****";
$db = mysql_connect($db_host,$db_user,$db_password);
if ($db == FALSE) die ("Errore durante la connessione al database: ".mysql_error());
mysql_select_db($db_name,$db) or die ("Errore nella selezione del database: ".mysql_error());
$query = "INSERT INTO ***nome tabella*** (titolo,news) VALUES ('$titolo','$news')";
mysql_query($query,$db);
mysql_close($db);
sostituisci al posto dei campi con **** xxx **** i valori corretti.
I'm your dreams, make you real... I'm your eyes when you must steel...I'm pain when you can't feel...sad but true !
Si ma qui per fare la teabella mi chiede di mettere i campi che metto??
devi fare un campo chiamato id che deve essere auto_increment e chiave primaria, poi metti due campi testuali uno chiamato titolo e l'altro news.
I'm your dreams, make you real... I'm your eyes when you must steel...I'm pain when you can't feel...sad but true !
Allora io ho fatto così
nella pagina aggiungi_news.html o messo questo
In aggiungi.phpcodice:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Aggiungi news</title> </head> <body> <form method="post" action="aggiungi.php"> Titolo: <input type="text" size="30" name="titolo"> Testo per la News: <textarea name="news" rows=10 cols=60> </textarea> <input type="submit" value="Invia"> </form> </body> </html>
o messo questo
é giusto poi ho fatto la tabella news con tre campi id Titolo ed News con cami text ed id int 11 giusto??codice:<?php $db_host = "localhost"; $db_user = "root"; $db_password =" "; $db_name = "News"; $db = mysql_connect($db_host,$db_user,$db_password); if ($db == FALSE) die ("Errore durante la connessione al database: ".mysql_error()); mysql_select_db($db_name,$db) or die ("Errore nella selezione del database: ".mysql_error()); $query = "INSERT INTO news (titolo,news) VALUES ('$titolo','$news')"; mysql_query($query,$db); mysql_close($db); ?>