I have a web page in PHP that displays an ad and below, users can ask questions about the product it sells. When loaded it does the following:
<?php
session_start();
require '../../includes/conexion.php';
include '../../includes/funcs_pdo.php';
include_once("../../includes/analyticstracking.php");
$codigo = base64_decode($_REQUEST['var']);
$conexion = new Conexion();
$stmt = $conexion -> prepare("SELECT T1.id, T1.titulo, T2.detalle as detalle2, T1.disponibles, T1.vendidos, T1.localizacion, T1.detalle, T1.foto, T1.precio, T1.forma_pago, T1.email, T1.telefono, T1.usuario, T1.idusuario, T1.lecturas FROM avisos as T1 INNER JOIN avisos_rubros as T2 ON T1.rubro = T2.id WHERE T1.id = :valor");
$stmt->bindParam(':valor', $codigo);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$idUsuarioVendedor = $row['idusuario'];
?>
The problem I have is that below I have the classic textarea with a button where the user asks the question, all within a form that I want to send to the same page by post. My question is where do I put the code of said post? after that? or before that code?
You could do it both ways, but if you want to use the value of
$idUsuarioVendedor
somewhere in your HTML, the logical thing to do would be to put the form after it. Also, you should check if the variable was POSTedvar