The HTML code follows:
- Code: Select all
<html><head><title>Bank 01</title></head><body>
<br/>
<form method="POST" action="register.php">
Band: <input type="text" name="band"><br/>
Album: <input type="text" name="album"><br/>
Year: <input type="text" name="year"><br/>
<input type="submit" value="Ok">
</form>
</body></html>
The PHP code:
- Code: Select all
<?php
$band = $_REQUEST['band'];
$album = $_REQUEST['album'];
$year = $_REQUEST['year'];
$url = "localhost";
$user = "root";
$pass = "";
if(!($id_conex = mysql_connect("$url", "$user", "$pass"))){
echo "MySQL error.";
exit;
}
$dbname= "cds";
if(!($conex = mysql_select_db($dbname, $id_conex))){
echo "Can't connect database.";
exit;
}
$sql = "INSERT INTO coll(banda, disco, ano) VALUES ($banda, $disco, $ano)";
$res = mysql_query($sql);
mysql_close($id_conexao);
?>
The SQL script:
- Code: Select all
CREATE DATABASE cds;
USE cds;
CREATE TABLE IF NOT EXISTS `coll` (
`id_cds` int(11) NOT NULL AUTO_INCREMENT,
`band` varchar(20) DEFAULT NULL,
`album` varchar(30) DEFAULT NULL,
`year` int(4) DEFAULT NULL,
PRIMARY KEY (`id_cds`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
Simply don't work, and I don't know why.
Anyone can help?
Thanks folks!
Té.


