FORO PHP Y MYSQL
ESCRITO POR: SUN2012 EL 27/SEP/2013
MYSQL, PHP, TUTORIALES
En esta ocasión realizare un foro básico con PHP y MYSQL.
Funciones que tendrá el foro:
Categorías de foros
Foros
Temas
Comentarios
Estadísticas: Lecturas del foro, mensajes, número de temas.
Usuarios
Panel de administración
Plantillas del foro
Empezaremos con la base de datos, puede que la actualicé como vayadesarrollando el foro.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
CREATE TABLE IF NOT EXISTS `foro_categoria` (
`id_forocategoria` int(4) NOT NULL AUTO_INCREMENT,
`categoria` varchar(250) NOT NULL,
`descripción` text NOT NULL,
PRIMARY KEY (`id_forocategoria`),
KEY `id_forocategoria`(`id_forocategoria`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `foro_subforos` (
`id_subforo` int(4) NOT NULL AUTO_INCREMENT,
`id_foro_categoria` int(4) NOT NULL,
`subforo` varchar(250) NOT NULL,
`descripción` text NOT NULL,
PRIMARY KEY (`id_subforo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `foro_temas` (
`id_tema` int(5) NOTNULL AUTO_INCREMENT,
`id_subforo` int(5) NOT NULL,
`titulo` varchar(250) NOT NULL,
`contenido` text NOT NULL,
`fecha` date NOT NULL,
`id_usuario` int(5) NOT NULL,
`activo` char(1) NOT NULL DEFAULT 'D',
PRIMARY KEY (`id_tema`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `comentario_foro` (
`id_comentario` int(5) NOT NULL AUTO_INCREMENT,
`id_tema` int(5) NOTNULL,
`idusuario` int(11) NOT NULL,
`comentario` text NOT NULL,
`fecha` date NOT NULL,
`activo` char(1) NOT NULL DEFAULT 'D',
PRIMARY KEY (`id_comentario`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `usuarios` (
`id` int(7) NOT NULL AUTO_INCREMENT,
`nickname` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`nombres` varchar(100) NOT NULLDEFAULT '',
`correo` varchar(100) NOT NULL,
`tipo` int(2) NOT NULL DEFAULT '0',
`facebook` varchar(250) NOT NULL,
`twitter` varchar(250) NOT NULL,
`fecharegistro` date NOT NULL,
`ultimoacceso` date NOT NULL,
`activo` int(2) NOT NULL DEFAULT '0',
`avatar` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
En la siguiente parte crearemos el front-end delforo y después el back-end.
FORO PHP Y MYSQL – PARTE 2
ESCRITO POR: SUN2012 EL 27/MAY/2014
MYSQL, PHP
En esta parte crearemos la parte visible por el usuario, este post abarca:
Estructura de la pagina principal el index y crearemos los archivos header.php y footer.php
Crearemos las clases principal, categorías, foros, subforos, temas
Conectaremos con la base de datos
Y crearemos parte del indexLa base de datos a sufrido algunos cambios de la del primer post, ya que se va adecuando y a completando al foro final.
Hasta donde llegaremos el foro quedara así más o menos.
Creamos la siguiente estructura de directorios:
class – guarda las clases creadas
css – hojas de estilo
img – imagenes
js – scripts jquery
Luego creamos nuestro index, header y footer con el siguiente codigo e incluimos elheader y el footer en el index
1
2
3
4
5
6
7
// pondremos los archivos class
include 'header.php'; // incluimos el header.php
// contenido del foro
include 'footer.php'; // incluimos el footer.php
En el archivo header.php empezamos con el código html y hoja de estilos, el encabezado del foro y los enlaces de registro y login
1
2
3
4
5
6
7
8
9
10
footer.php cerramos el html
1
2
Ya que tenemos la estructura empezaremos con la class principal.php que conecta a la base de datos y define la ruta del sitio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26...
Regístrate para leer el documento completo.