I need to pass the same value to identify which user enters each column, Do not make a select with inner join, if not pass the data. I have two tables
- tabla rusa (id_usu auto incrementable pk, usuario, password, checkbox)
- tabla contenido (id_con auto incrementable pk, negocio, slogan, id_rusa fk)
I need the tables to take the values:
- id_usu id_rusa
- 1 1
- 2 2
- 1 1
example:
- id_usu, usuario, password
- 1, juan, 4578
- id_con negocio slogan id_rusa
- 10, carnitas , la mejor , 1
- 11 , barbacoa , sabrosa , 1
<?php session_start();
if (isset($_SESSION['usuario'])) {
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$negocio = $_POST['negocio'];
$slogan = $_POST['slogan'];
$imagen = $_FILES['imagen']['tmp_name'];
$ubicacion = $_POST['ubicacion'];
$web = $_POST['web'];
$telefono = $_POST['telefono'];
$errores = '';
if (empty($negocio)) {
$errores .= '<li>Por favor rellena todos los datos correctamente</li>';
} else {
try {
$conexion = new PDO('mysql:host=localhost;dbname=anunciate', 'root', '');
$sql = 'INSERT INTO contenido (negocio, slogan, imagen, ubicacion, web, telefono)
VALUES (:negocio, :slogan, :imagen, :ubicacion, :web, :telefono)';
$res=$conexion->prepare($sql);
$res->execute(array(
':negocio' => $negocio,
':slogan' => $slogan,
':imagen' => $imagen,
':ubicacion' => $ubicacion,
':web' => $web,
':telefono' => $telefono,
'id_rusa' => $row));
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
}
require 'views/contenido.view.php';
?>