Files correlati : Ricompilazione Demo : [ ] Commento : Prime modifiche git-svn-id: svn://10.65.10.50/trunk@9788 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			178 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			178 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| <html>
 | |
| <head>
 | |
| 	<title>Corsi</title>
 | |
| 	<LINK rel="stylesheet" type="text/css" href="stile.css">
 | |
| </head>
 | |
| 
 | |
| <body>
 | |
| 
 | |
| <?php
 | |
| 
 | |
| if (isset($dbname) && ($dbname != ""))
 | |
| {
 | |
| 	$query = mysql_query("CREATE DATABASE $dbname");
 | |
| 	if (!$query)
 | |
| 	   mysql_die();
 | |
| 	else
 | |
| 	{
 | |
| 		$link = mysql_connect("localhost", "root", "");
 | |
| 		if (!$link)
 | |
| 			die("Impossibile connettersi a MySQL");
 | |
| 		mysql_select_db($dbname, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'accessi'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE accessi (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   idutente int(11) NOT NULL,
 | |
| 		   login datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
 | |
| 		   logout datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
 | |
| 		   descrizione text NOT NULL,
 | |
| 		   modifica varchar(10) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idutente (idutente),
 | |
| 		   KEY login (login),
 | |
| 		   KEY logout (logout)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'corsi'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE corsi (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   nome varchar(100) NOT NULL,
 | |
| 		   descrizione text,
 | |
| 		   costo bigint(20),
 | |
| 		   immagine varchar(50) NOT NULL,
 | |
| 		   test_prima varchar(10) DEFAULT 'Falso' NOT NULL,
 | |
| 		   modo int(11) NOT NULL,
 | |
| 		   PRIMARY KEY (id)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'domande'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE domande (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   idtest int(11) NOT NULL,
 | |
| 		   domanda text NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idtest (idtest)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'download'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE download (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   idutente int(11) NOT NULL,
 | |
| 		   idlezione int(11) NOT NULL,
 | |
| 		   data date DEFAULT '0000-00-00' NOT NULL,
 | |
| 		   terminato varchar(10) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idutente (idutente),
 | |
| 		   KEY idlezione (idlezione)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'lezioni'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE lezioni (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   idcorso int(11) NOT NULL,
 | |
| 		   nome varchar(255) NOT NULL,
 | |
| 		   progressivo smallint(6) NOT NULL,
 | |
| 		   percorso varchar(50) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idcorso (idcorso)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'prove'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE prove (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   idutente int(11) NOT NULL,
 | |
| 		   idtest int(11) NOT NULL,
 | |
| 		   data date DEFAULT '0000-00-00' NOT NULL,
 | |
| 		   risultato varchar(20) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idutente (idutente),
 | |
| 		   KEY idtest (idtest)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'risposte'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE risposte (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   iddomanda int(11) NOT NULL,
 | |
| 		   risposta text NOT NULL,
 | |
| 		   valida varchar(10) NOT NULL,
 | |
| 		   visibile varchar(10) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY iddomanda (iddomanda)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'test'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE test (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   idlezione int(11) NOT NULL,
 | |
| 		   nome varchar(255) NOT NULL,
 | |
| 		   posizione varchar(10) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idlezione (idlezione)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		
 | |
| 		# Struttura della tavola 'utenti'
 | |
| 		
 | |
| 		$criteri = "CREATE TABLE utenti (
 | |
| 		   id int(11) NOT NULL auto_increment,
 | |
| 		   nome varchar(25) NOT NULL,
 | |
| 		   cognome varchar(25) NOT NULL,
 | |
| 		   email varchar(35) NOT NULL,
 | |
| 		   username varchar(20) NOT NULL,
 | |
| 		   pass varchar(20) NOT NULL,
 | |
| 		   data date DEFAULT '0000-00-00' NOT NULL,
 | |
| 		   idcorso varchar(5) NOT NULL,
 | |
| 		   PRIMARY KEY (id),
 | |
| 		   KEY idcorso (idcorso)
 | |
| 		)";
 | |
| 		echo "<p>".$criteri."</p>";
 | |
| 		$query = mysql_query($criteri, $link);
 | |
| 		
 | |
| 		echo "<p class=success>Database $dbname creato con successo!</p>";
 | |
| 	}
 | |
| }
 | |
| else
 | |
| {
 | |
| 	echo "<form name=creadb action=$PHP_SELF? method=post><table align=center>";
 | |
| 	echo "<tr><td>Nome del database</td><td><input type=text name=dbname></td></tr>";
 | |
| 	echo "<tr><td colspan=2 align=center><input type=submit value='Crea Database'></td></tr>";
 | |
| 	echo "</table></form>";
 | |
| }
 | |
| 
 | |
| ?>
 | |
| 
 | |
| 
 |