I put my code to register but at the time of saving, I do not save anything in the database. This table is taken from the internet and works well, but I added two more fields, address and email, but when saving the data, does not save anything in my table, I know that I have to change mysql for mysqli or PDO, but I do not think that the fault is there thank you very much
<?php
error_reporting(0);
//print_r($_POST);
include "conexion.php";
if(isset($_POST))
{
$insert="INSERT INTO contacto
(nombre,apellido_paterno,apellido_materno,telefono,direccion,email)
VALUES(
'".$_POST['nombre']."',
'".$_POST['apellido_paterno']."',
'".$_POST['apellido_materno']."',
'".$_POST['telefono']."',
'".$_POST['direccion']."',
'".$_POST['email']."'
)";
//print_r($insert);
mysql_query($insert, $link);
}
?>
<html>
<head>
<title>Mi Agenda</title>
<link rel="stylesheet" href="estilos.css" type="text/css" media=screen>
</head>
<body>
<div id="container">
<div id="header"><b>Mi Agenda</b></div>
<div id="menu">
<div class="seccion"><a href="index.html">Inicio</a></div>
<div class="seccion"><a href="registrar.php">Registrar contacto</a>
</div>
<div class="seccion"><a href="listar.php">Listar contacto</a></div>
</div>
<div id="content">
<h2>Registrar contacto</h2>
<form method="POST">
<table>
<tr>
<td><label>Nombre:</label></td>
<td><input type="text" name="nombre"/></td>
</tr>
<tr>
<td><label>Apellido Paterno:</label></td>
<td><input type="text" name="apellido_paterno"/></td>
</tr>
<tr>
<td><label>Apellido Materno:</label></td>
<td><input type="text" name="apellido_materno"/></td>
</tr>
<tr>
<td><label>Telefono:</label></td>
<td><input type="text" name="telefono"/></td>
</tr>
<tr>
<td><label>direccion:</label></td>
<td><input type="text" name="direccion"/></td>
</tr>
<tr>
<td><label>Email:</label></td>
<td><input type="text" name="email"/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Aceptar"/>
<input type="reset" value="Cancelar"/></td>
</tr>
</table>
</form>
</div>
<div id="footer">Desarrollado por Diego - Copyright Todos los Derechos
Reservados</div>
</div>
</body>
</html>
<?php
mysql_close($link);
?>
my code to list
<?php
include "conexion.php";
$query="SELECT * FROM contacto";
$resultado = mysql_query($query);
//print_r($resultado);
while ($fila = mysql_fetch_array($resultado))
{
//print_r($fila);
$contactos[]=$fila;
}
//print_r($contactos);
?>
<html>
<head>
<title>Mi agenda</title>
<link rel="stylesheet" href="estilos.css" type="text/css" media=screen>
</style>
</head>
<body>
<div id="container">
<div id="header"><b>Mi Agenda</b></div>
<div id="menu">
<div class="seccion"><a href="index.html">Inicio</a></div>
<div class="seccion"><a href="registrar.php">Registrar contacto</a>
</div>
<div class="seccion"><a href="listar.php">Listar contacto</a></div>
</div>
<div id="content">
<h2>Lista de contactos</h2>
<table>
<tr>
<th>#</th>
<th>Nombre</th>
<th>Apellido Paterno</th>
<th>Apellido Materno</th>
<th>Teléfono</th>
<th>direccion</th>
<th>email</th>
</tr>
<?php
foreach($contactos as $c)
{
echo"
<tr>
<td>".$c['id']."</td>
<td>".$c['nombre']."</td>
<td>".$c['apellido_paterno']."</td>
<td>".$c['apellido_materno']."</td>
<td>".$c['telefono']."</td>
<td>".$c['direcion']."</td>
<td>".$c['email']."</td>
</tr>
";
}
?>
</table>
</div>
<div id="footer">Desarrollado por Diego - Copyright Todos los Derechos
Reservados</div>
</div>
</body>
</html>
<?php
mysql_close($link);
?>
my ensql table
-- phpMyAdmin SQL Dump
-- version 4.6.4
-- https://www.phpmyadmin.net/
--
-- Servidor: X.X.X.99
-- Tiempo de generación: 06-04-2017 a las 18:55:14
-- Versión del servidor: 5.7.14
-- Versión de PHP: 5.6.25
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: '***********'
--
--
-- Estructura de tabla para la tabla 'contacto'
--
CREATE TABLE 'contacto' (
'id' bigint(20) NOT NULL,
'apellido_paterno' text NOT NULL,
'apellido_materno' text NOT NULL,
'nombre' text NOT NULL,
'foto' text NOT NULL,
'telefono' text NOT NULL,
'direccion' text NOT NULL,
'email' text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Ãndices para tablas volcadas
--
--
-- Indices de la tabla 'contacto'
--
ALTER TABLE 'contacto'
ADD PRIMARY KEY ('id');
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla 'contacto'
--
ALTER TABLE 'contacto'
MODIFY 'id' bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;